Part Number Hot Search : 
2SK3298 JW050A N4937 9F200 IT2009 Q1148 Q1148 AS4PD
Product Description
Full Text Search
 

To Download AT32AP7002-CTUR Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  features ? high performance, low power avr ? 32 32-bit microcontroller ? 210 dmips throughput at 150 mhz ? 16 kb instruction cache and 16 kb data caches ? memory management unit enab ling use of operating systems ? single-cycle risc instruction set including simd and dsp instructions ? java hardware acceleration ? pixel co-processor ? pixel co-processor for video acceler ation through color-space conversion (yuv<->rgb), image scalin g and filtering, quarter pixel motion compensation ? multi-hierarchy bus system ? high-performance data transfers on separate buses for increased performance ? data memories ? 32kbytes sram ? external memory interface ? sdram, dataflash ? , sram, multi media card (mmc), secure digital (sd), ? compact flash, smart media, nand flash ? direct memory access controller ? external memory access without cpu intervention ? interrupt controller ? individually maskable interrupts ? each interrupt request has a programm able priority and autovector address ? system functions ? power and clock manager ? crystal oscillator wit h phase-lock-loop (pll) ? watchdog timer ? real-time clock ? 6 multifunction timer/counters ? three external clock inputs, i/o pins, pwm, capture and various counting capabilities ? 4 universal synchronous/asynchrono us receiver/transmitters (usart) ? 115.2 kbps irda modulation and demodulation ? hardware and software handshaking ? 3 synchronous serial protocol controllers ? supports i2s, spi and gene ric frame-based protocols ? two-wire interface ? sequential read/write operations, philips? i2c? compatible ? liquid crystal disp lay (lcd) interface ? supports tft displays ? configurable pixel resolution supporting qcif/qvga/vga/svga configurations. ? image sensor interface ? 12-bit data interface for cmos cameras ? universal serial bus (usb) 2.0 high speed (480 mbps) device ? on-chip transceivers with physical interface ? 16-bit stereo audio bitstream dac ? sample rates up to 50 khz ? on-chip debug system ? nexus class 3 ? full speed, non-intrusive data and program trace ? runtime control and jtag interface ? package/pins ? at32ap7002: 196-ball ctbga ? power supplies ? 1.65v to1.95v vddcore ? 3.0v to 3.6v vddio 32054f-avr32-09/09 avr ? 32 32-bit microcontroller at32ap7002 preliminary
2 32054f?avr32?09/09 at32ap7002 1. part description the at32ap7002 is a complete system-on-chip application processor with an avr32 risc processor achieving 210 dmips running 150 mhz. avr32 is a high-performance 32-bit risc microprocessor core, designed for cost-sensitive embedded applications, with particular empha- sis on low power consumption, high code density and high application performance. at32ap7002 implements a memory management unit (mmu) and a flexible interrupt controller supporting modern operating systems and real-time operating systems. the processor also includes a rich set of dsp and simd instructio ns, specially designed fo r multimedia and telecom applications. at32ap7002 incorporates sram memories on-chip for fast and secure access. for applica- tions requiring additional memory, external 16-bit sram is accessible. additionally, an sdram controller provides off-chip volat ile memory access as well as cont rollers for all industry standard off-chip non-volatile memories, like compact flash, multi media card (mmc), secure digital (sd)-card, smartcard, nand flash and atmel dataflash?. the direct memory access controller for all the serial peripherals enables data transfer between memories without processor intervention. this reduces the processor overhead when transfer- ring continuous and large data streams between modules in the mcu. the timer/counters includes three identical 16-bit timer/counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measure- ment, event counting, interval measurement, pulse generation, delay timing and pulse width modulation. at32ap7002 also features an onboard lcd controller, supporting single and double scan monochrome and color passive stn lcd modul es and single scan acti ve tft lcd modules. on monochrome stn displays, up to 16 gray shades are supported using a time-based dither- ing algorithm and frame rate control (frc) method. this method is also used in color stn displays to generate up to 4096 colors. the lcd controller is programmable for supporting resolutions up to 2048 x 2048 with a pixel depth from 1 to 24 bits per pixel. a pixel co-processor provides color space conv ersions for images and video, in addition to a wide variety of hardware filter support the media-independent interface (mii) and reduced mii (rmii) 10/100 ethernet mac modules provides on-chip solutions for network-connected devices. synchronous serial controllers provide easy ac cess to serial communication protocols, audio standards like i2s and frame-based protocols. the java hardware acceleration implementation in avr32 allows for a very high-speed java byte-code execution. avr32 implements java in structions in hardware, reusing the existing risc data path, which allows for a near-zero hardware overhead and cost with a very high performance. the image sensor interface supports cameras with up to 12-bit data buses. ps2 connectivity is provided for standa rd input devices like mice and keyboards.
3 32054f?avr32?09/09 at32ap7002 at32ap7002 integrates a class 3 nexus 2.0 on -chip debug (ocd) system, with non-intrusive real-time trace, full-speed read/write memory access in addition to basic runtime control. the c-compiler is closely linked to the architecture and is able to utilize code optimization fea- tures, both for size and speed.
4 32054f?avr32?09/09 at32ap7002 2. signals description the following table gives details on the signal name classified by peripheral. the pinout multi- plexing of these signals is given in the perip heral muxing table in the peripherals chapter. table 2-1. signal description list signal name function type active level comments power avddpll pll power supply power 1.65 to 1.95 v avddusb usb power supply power 1.65 to 1.95 v avddosc oscillator power supply power 1.65 to 1.95 v vddcore core power supply power 1.65 to 1.95 v vddio i/o power supply power 3.0 to 3.6v agndpll pll ground ground agndusb usb ground ground agndosc oscillator ground ground gnd ground ground clocks, oscillators, and pll?s xin0, xin1, xin32 crystal 0, 1, 32 input analog xout0, xout1, xout32 crystal 0, 1, 32 output analog pll0, pll1 pll 0,1 filter pin analog jtag tck test clock input tdi test data in input tdo test data out output tms test mode select input trst_n test reset input low auxiliary port - aux mcko trace data output clock output mdo0 - mdo5 trace data output output mseo0 - mseo1 trace frame control output evti_n event in input low
5 32054f?avr32?09/09 at32ap7002 evto_n event out output low power manager - pm gclk0 - gclk4 generic clock pins output oscen_n oscillator enable input low reset_n reset pin input low wake_n wake pin input low external interrup t controller - eic extint0 - extint3 external interrupt pins input nmi_n non-maskable interrupt pin input low ac97 controller - ac97c sclk ac97 clock signal input sdi ac97 receive signal output sdo ac97 transmit signal output sync ac97 frame synchronization signal input audio bitstream dac - abdac data0 - data1 d/a data out output datan0 - datan1 d/a inverted data out output external bus interface - ebi px0 - px53 i/o controlled by ebi i/o addr0 - addr25 address bus output cas column signal output low cfce1 compact flash 1 chip enable output low cfce2 compact flash 2 chip enable output low cfrnw compact flash read not write output data0 - data31 data bus i/o nandoe nand flash output enable output low nandwe nand flash write enable output low ncs0 - ncs5 chip select output low table 2-1. signal description list signal name function type active level comments
6 32054f?avr32?09/09 at32ap7002 nrd read signal output low nwait external wait signal input low nwe0 write enable 0 output low nwe1 write enable 1 output low nwe3 write enable 3 output low ras row signal output low sda10 sdram address 10 line output sdck sdram clock output sdcke sdram clock enable output sdwe sdram write enable output low image sensor interface - isi data0 - data11 image sensor data input hsync horizontal synchronization input pclk image sensor data clock input vsync vertical synchronization input lcd controller - lcdc cc lcd contrast control output data0 - data23 lcd data bus input dval lcd data valid output gpl0 - gpl7 lcd general purpose lines output hsync lcd horizontal synchronization output mode lcd mode output pclk lcd clock output pwr lcd power output vsync lcd vertical synchronization output multimedia card interface - mci clk multimedia card clock output cmd0 - cmd1 multimedia card command i/o table 2-1. signal description list signal name function type active level comments
7 32054f?avr32?09/09 at32ap7002 data0 - data7 multimedia card data i/o parallel input/output - pioa, piob, pioc, piod pa0 - pa31 parallel i/o controller pioa i/o pb0 - pb30 parallel i/o controller piob i/o pc20 - pc23/ pc28 - pc31 parallel i/o controller pioc i/o pd0 - pd17 parallel i/o controller piod i/o ps2 interface - psif clock0 - clock1 ps2 clock input data0 - data1 ps2 data i/o serial peripheral in terface - spi0, spi1 miso master in slave out i/o mosi master out slave in i/o npcs0 - npcs3 spi peripheral chip select i/o low sck clock output synchronous serial contro ller - ssc0, ssc1, ssc2 rx_clock ssc receive clock i/o rx_data ssc receive data input rx_frame_sync ssc receive frame sync i/o tx_clock ssc transmit clock i/o tx_data ssc transmit data output tx_frame_sync ssc transmit frame sync i/o dma controller - dmaca dmarq0 - dmarq3 dma requests input timer/counter - timer0, timer1 a0 channel 0 line a i/o a1 channel 1 line a i/o a2 channel 2 line a i/o b0 channel 0 line b i/o table 2-1. signal description list signal name function type active level comments
8 32054f?avr32?09/09 at32ap7002 b1 channel 1 line b i/o b2 channel 2 line b i/o clk0 channel 0 external clock input input clk1 channel 1 external clock input input clk2 channel 2 external clock input input two-wire interface - twi scl serial clock i/o sda serial data i/o universal synchronous asynchronous receiver transmitter - usart0, usart1, usart2, usart3 clk clock i/o cts clear to send input rts request to send output rxd receive data input txd transmit data output pulse width modulator - pwm pwm0 - pwm3 pwm output pins output usb interface - usba hsdm high speed usb interface data - analog fsdm full speed usb interface data - analog hsdp high speed usb interface data + analog fsdp full speed usb interface data + analog vbg usb bandgap analog connected to a 6810 ohm 0.5% resistor to gound and a 10 pf capacitor to ground. table 2-1. signal description list signal name function type active level comments
9 32054f?avr32?09/09 at32ap7002 3. power considerations 3.1 power supplies the at32ap7002 has several types of power supply pins: ? vddcore pins: power the core , memories, and peripherals. voltage is 1.8v nominal. ? vddio pins: power i/o lines. voltage is 3.3v nominal. ? vddpll pin: powers the pll. voltage is 1.8v nominal. ? vddusb pin: powers the usb. voltage is 1.8v nominal. ? vddosc pin: powers the oscillat ors. voltage is 1.8v nominal. the ground pins gnd are common to vddcore and vddio. the ground pin for vddpll is gndpll, and the gnd pin for vddosc is gndosc. see ?electrical characteristics? on page 862 for power consumption on the various supply pins. 3.2 power supply connections special considerations should be made when connecting the power and ground pins on a pcb. figure 3-1 shows how this should be done. figure 3-1. connecting analog power supplies avddusb avddpll avddosc agndusb agndpll agndosc vddcore vcc_1v8 3.3uh c54 0.10u c55 0.10u c56 0.10u
10 32054f?avr32?09/09 at32ap7002 3.3 package and pinout avr32ap7002 figure 3-2. 196 ctbga pinout top view bottom view ball a1 avr32 a b c d e f g h j k l m n p a b c d e f g h j k l m n p 14 13 12 11 10 9 8 7 6 5 4 3 2 1 1413121110 9 8 7 6 5 4 3 2 1 table 3-1. ctbga196 package pinout a1..t8 12345678 a px49 px48 px47 avddpll pc28 pc23 pc20 pb22 b px50 gnd vddio pll0 pll1 xin32 pc22 pb23 c px51 pd01 px05 gnd agndpll xout32 pc29 pc21 d px32 pd00 vddio px02 xin0 xout0 agndosc pc30 e px33 px00 px04 gnd pd07 avddosc oscen_n pc31 f px01 px03 vddcore pd04 pd09 tdi reset_n vddcore g pd05 pd08 pd06 tdo pa04 pa02 pa08 px22 h tms trst_n tck evti_n pb24 pa10 pa14 px38 j pa 0 1 pa 0 3 pa 0 0 v d d i o g n d pa 0 9 pa 1 8 g n d k pa 0 5 pa 1 1 pa 1 2 pa 1 6 g n d g n d pa 2 6 wa k e _ n l pb25 pa21 pa19 gnd vddio vddio pa25 pa29 m pa13 pa22 pa23 pd17 avddusb vddcore vbg pa30 n pa15 pa20 pd12 pd15 pd16 agndusb fsdp hsdp p pa17 pa24 pd13 pd14 xin1 xout1 fsdm hsdm
11 32054f?avr32?09/09 at32ap7002 table 3-2. ctbga196 package pinout a9..t16 9 1011121314 a pb18 pb16 pb11 pb08 pb05 pb04 b pb21 pb17 pb12 pb09 pb06 pb03 c pa06 pb19 pb14 pb10 pb07 pb02 d vddio pb20 pb15 pb13 gnd pb01 e pa07 gnd pb00 px44 vddio px45 f px42 gnd gnd px43 px46 px40 g px30 px25 px31 vddio vddcore px39 h pa28 px20 px28 px29 vddcore px26 j pb27 px37 px23 px27 px21 px24 k pb28 px15 px36 px19 px34 px18 l px41 gnd px07 vddio gnd px35 m px53 px06 px11 px12 px17 px14 n pb26 vddio px09 pb29 px16 px13 p pa27 pa31 px52 px08 px10 pb30
12 32054f?avr32?09/09 at32ap7002 4. blockdiagram figure 4-1. blockdiagram data[11..0] hsync vsync pclk ap cpu nexus class 3 ocd instr cache data cache timer/counter 0/1 interrupt controller real time counter peripheral dma controller intram0 intram1 hsb-pb bridge b hsb-pb bridge a s m m m s s s m external interrupt controller high speed bus matrix parallel input/output controllers pixel coprocessor parallel input/output controllers reset_n pa pb pc pd pe a [ 2 . . 0 ] b [ 2 . . 0 ] clk[2..0] e x t i n t [ 7 . . 0 ] k p s [ 7 . . 0 ] nmi_n g c l k [ 3 . . 0 ] xin32 xout32 xin0 xout0 pa pb pc pd pe external bus interface (sdram & static memory controller & ecc) ncs[5,4,2] cfrnw, cfce1, cfce2, addr[23..25] nwait data[15..0] usb interface dma d- d+ 32 khz osc osc0 pll0 ps2 interface serial peripheral interface 0/1 two-wire interface pdc miso, mosi npcs[3..1] scl sda usart0 usart1 usart2 usart3 pdc rxd txd clk rts, cts synchronous serial controller 0/1/2 pdc tx_clock, tx_frame_sync rx_data tx_data rx_clock, rx_frame_sync watchdog timer xin1 xout1 osc1 pll1 sck jtag interface mcko mdo[5..0] mseo[1..0] evti_n evto_n tck tdo tdi tms power manager reset controller sleep controller clock controller clock generator configuration registers bus memory management unit pb pb hsb hs b pba pbb npcs0 m s clock[1..0] data[1..0] hsb-hsb bridge trst_n data[31..16] oscen_n pll0 pll1 dma controller s m m audio bitstream dac dma multimedia card interface dma ac97 controller dma s c l k s d i s s y n c s d o c l k cmd data[7..0] d a t a 0 d a t a 1 d a t a 0 n d a t a 1 n pulse width modulation controller pwm0 pwm1 pwm2 pwm3 image sensor interface m lcd contro ller dma m s vsync, hsync, pwr, pclk, mode, dval, cc, data[22..0], gpl[7..0] ras, cas, sdwe, nandoe, nandwe, sdck, sdcke, nwe3, nwe1, nwe0, nrd, ncs[3,1,0], addr[22..0]
13 32054f?avr32?09/09 at32ap7002 4.0.1 avr32ap cpu ? 32-bit load/store avr32b risc architecture. ? up to 15 general-purpose 32-bit registers. ? 32-bit stack pointer, program counter and link register reside in register file. ? fully orthogonal instruction set. ? privileged and unprivileged modes enabling efficient and secure operating systems. ? innovative instruction set together with variable instruction length ensu ring industry leading code density. ? dsp extention with saturating arithmetic, and a wide variet y of multiply instructions. ? simd extention for media applications. ? 7 stage pipeline allows one instruction per clock cycle for most instructions. ? java hardware acceleration. ? byte, half-word, word and double word memory access. ? unaligned memory access. ? shadowed interrupt context for int3 an d multiple interrupt priority levels. ? dynamic branch prediction and return address stac k for fast change-of-flow. ? coprocessor interface. ? full mmu allows for operating systems with memory protection. ? 16kbyte instruction and 16kbyte data caches. ? virtually indexed, physically tagged. ? 4-way associative. ? write-through or write-back. ? nexus class 3 on-chip debug system. ? low-cost nanotrace supported. 4.0.2 pixel coprocessor (pico) ? coprocessor coupled to the avr3 2 cpu core through the tcb bus. ? coprocessor number one on the tcb bus. ? three parallel vector multiplicati on units (vmu) where each unit can: ? multiply three pixel componen ts with three coefficients. ? add the products from the multiplications together. ? accumulate the result or add an o ffset to the sum of the products. ? can be used for accelerating: ? image color space conversion. ?configurable conver sion coefficients. ? supports packed and planar input and output formats. ? supports subsampled input color spaces (i.e 4:2:2, 4:2:0). ? image filtering/scaling. ? configurable filter coefficients. ? throughput of one sample per cycle for a 9-tap fir filter. ? can use the built-in accumulator to extend the fir filter to more than 9-taps. ? can be used for bilinear/bicubic interpolations. ? mpeg-4/h.264 quarter pi xel motion compensation. ? flexible input pixel selector. ? can operate on numerous different image storage formats. ? flexible output pixel inserter. ? scales and saturates the results back to 8-bit pixel values. ? supports packed and planar output formats.
14 32054f?avr32?09/09 at32ap7002 ? configurable coefficien ts with flexible fixe d-point representation. 4.0.3 debug and test system ? ieee1149.1 compliant jtag and boundary scan ? direct memory access and programming capabilities through jtag interface ? extensive on-chip debug features in compliance with ieee-isto 5001-2003 (nexus 2.0) class 3 ? auxiliary port for high-speed trace information ? hardware support for 6 program and 2 data breakpoints ? unlimited number of softw are breakpoints supported ? advanced program, data, ownership, and watchpoint trace supported 4.0.4 dma controller ? 2 hsb master interfaces ? 3 channels ? software and hardware handshaking interfaces ? 11 hardware handshaking interfaces ? memory/non-memory periph erals to memory/non-mem ory peripherals transfer ? single-block dma transfer ? multi-block dma transfer ? linked lists ? auto-reloading ? contiguous blocks ? dma controller is always the flow controller ? additional features ? scatter and gather operations ? channel locking ? bus locking ? fifo mode ? pseudo fly-by operation 4.0.5 peripheral dma controller ? transfers from/to peripheral to/from any memory space without interven tion of the processor. ? next pointer support, forbids strong real -time constraints on buffer management. ? eighteen channels ? two for each usart ? two for each serial synchronous controller ? two for each serial peripheral interface 4.0.6 bus system ? hsb bus matrix with 10 masters and 8 slaves handled ? handles requests from the cpu icache, cpu d cache, hsb bridge, hisi, usb 2.0 controller, lcd controller, dma controller 0, dma controller 1, and to internal sram 0, internal sram 1, pb a, pb b, ebi and, usb.
15 32054f?avr32?09/09 at32ap7002 ? round-robin arbitration (three modes supported: no default master, last accessed default master, fixed default master) ? burst breaking with slot cycle limit ? one address decoder provided per master ? 2 peripheral buses allowing each bu s to run on different bus speeds. ? pb a intended to run on low clock speed s, with peripherals co nnected to the pdc. ? pb b intended to run on higher clock spee ds, with peripherals connected to the dmaca. ? hsb-hsb bridge providing a low-speed hs b bus running at the same speed as pba ? allows pdc transfers between a low-speed pb bus and a bus matrix of higher clock speeds an overview of the bus system is given in figure 4-1 on page 12 . all modules connected to the same bus use the same clock, but the clock to each module can be individually shut off by the power manager. the figure identifies the number of master and slave interfaces of each module connected to the hsb bus, and which dma controller is connected to which peripheral.
16 32054f?avr32?09/09 at32ap7002 5. i/o line considerations 5.1 jtag pins the tms, tdi and tck pins have pull-up resistors. tdo is an output, driven at up to vddio, and have no pull-up resistor. the trst_n pin is used to initialize the embedded jtag tap controller when asserted at a low level. it is a schmitt input and integrates permanent pull-up resistor to vddio, so that it can be left unconnected for normal operations. 5.2 wake_n pin the wake_n pin is a schmitt trig ger input integr ating a permanent pull-up resistor to vddio. 5.3 reset_n pin the reset_n pin is a schmitt input and integrates a permanent pull-up resistor to vddio. as the product integrat es a power-on reset cell, the reset_n pin can be left unconnected in case no reset from the system needs to be applied to the product. 5.4 evti_n pin the evti_n pin is a schmitt input and integrates a non-programmable pull-up resistor to vddio. 5.5 twi pins when these pins are used for twi, the pins are open-drain outputs with slew-rate limitation and inputs with inputs with spike-filtering. when used as gpio-pins or used for other peripherals, the pins have the same characteristics as pio pins. 5.6 pio pins all the i/o lines integrate a programmable pull-up resistor . programming of this pull-up resistor is performed independently for each i/o line through the pio controllers. after reset, i/o lines default as inputs with pull-up resistors enabled, ex cept when indicated otherwise in the column ?reset state? of the pio controller multiplexing tables.
17 32054f?avr32?09/09 at32ap7002 6. avr32 ap cpu rev.: 1.0.0.0 this chapter gives an overview of the avr32 ap cpu. avr32 ap is an implementation of the avr32 architecture. a summary of the programming model, instruction set, caches and mmu is presented. for further details, see the avr32 architecture manual and the avr32 ap technical reference manual . 6.1 avr32 architecture avr32 is a new, high-performance 32-bit risc mi croprocessor architectu re, designed for cost- sensitive embedded applications, with particul ar emphasis on low power consumption and high code density. in addition, the instruction set architecture has been tuned to allow a variety of microarchitectures, enabling the avr32 to be im plemented as low-, mid- or high-performance processors. avr32 extends the avr family into the world of 32- and 64-bit applications. through a quantitative approach, a large set of industry recognized benchmarks has been com- piled and analyzed to achieve the best code density in its class. in addition to lowering the memory requirements, a compact code size also contributes to the core?s low power characteris- tics. the processor supports byte and half-word data types without penalty in code size and performance. memory load and store operations are provided for byte, half-word, word and double word data with automatic sign- or zero extension of half-word and byte data. in order to reduce code size to a minimum, so me instructions have multiple addressing modes. as an example, instructions with immediates often have a compact format with a smaller imme- diate, and an extended format with a larger immediate. in this way, the compiler is able to use the format giving the smallest code size. another feature of the instruction set is that frequently used instructions, like add, have a com- pact format with two operands as well as an extended format with three operands. the larger format increases performance, allowing an addition and a data move in the same instruction in a single cycle. load and store instructions have seve ral different formats in order to reduce code size and speed up execution. the register file is organized as sixteen 32-bi t registers and includes the program counter, the link register, and the stack pointer. in addition, register r12 is designed to hold return values from function calls and is used im plicitly by some instructions. 6.2 the avr32 ap cpu avr32 ap targets high-performance applications, and provides an advanced ocd system, effi- cient data and instruction caches, and a full mmu. figure 6-1 on page 18 displays the contents of avr32 ap.
18 32054f?avr32?09/09 at32ap7002 figure 6-1. overview of the avr32 ap cpu 6.2.1 pipeline overview avr32 ap is a pipelined processor with seven pipe line stages. the pipeline has three subpipes, namely the multiply pipe, the execute pipe and the data pipe. these pipelines may execute dif- ferent instructions in parallel. instructions are issued in order, but may complete out of order (ooo) since the subpipes may be stalled individ ually, and certain operations may use a subpipe for several clock cycles. figure 6-2 on page 19 shows an overview of the avr32 ap pipeline stages. avr32 cpu pipeline with java accelerator dcache controller hsb master icache controller hsb master 32-entry tlb 8-entry utlb 4-entry utlb mmu high speed bus high speed bus cache ram interface cache ram interface btb ram interface tightly coupled bus ocd system ocd interface reset control reset interface interrupt controller interface jtag control jtag interface
19 32054f?avr32?09/09 at32ap7002 figure 6-2. the avr32 ap pipeline .the follwing abbreviations are used in the figure: ?if1, if2 - instruction fetch stage 1 and 2 ?id - instruction decode ?is - instruction issue ?a1, a2 - alu stage 1 and 2 ?m1, m2 - multiply stage 1 and 2 ?da - data address calculation stage ?d - data cache access ?wb - writeback 6.2.2 avr32b microarchitecture compliance avr32 ap implements an avr32b microarchitec ture. the avr32b microarchitecture is tar- geted at applications where interrupt latency is important. the avr32b therefore implements dedicated registers to hold the status register and return address for interrupts, exceptions and supervisor calls. this information does not need to be written to the stack, and latency is there- fore reduced. additionally, avr32b allows hardware shadowing of the registers in the register file. the scall , rete and rets instructions use the dedicated return status registers and return address registers in their operation. no stack accesses are performed by these instructions. 6.2.3 java support avr32 ap provides java hardware acceleration in the form of a java virtual machine hardware implementation. refer to the avr32 java technical reference manual for details. 6.2.4 memory management avr32 ap implements a full mmu as specified by the avr32 architecture. the page sizes pro- vided are 1k, 4k, 64k and 1m. a 32-entry fully-associative common tlb is implemented, as well as a 4-entry micro-itlb and 8-entry micro-dtlb. instruction and data accesses perform lookups in the micro-tlbs. if the access misses in the mi cro-tlbs, an access in the common tlb is per- formed. if this access misses, a page miss exception is issued. if2 id is a1 m1 m2 d wb prefetch unit decode unit alu pipe multiply pipe load-store pipe da a2 if1
20 32054f?avr32?09/09 at32ap7002 6.2.5 caches and write buffer avr32 ap implements 16k data and 16k instruction caches. the caches are 4-way set asso- ciative. each cache has a 32-bit system bus master interface connecting it to the bus. the instruction cache has a 32-bit interface to the fetch pipeline stage, and the data cache has a 64- bit interface to the load-store pipeline. the cac hes use a least recently used allocate-on-read- miss replacement policy. the caches are virtually tagged, physically indexed, avoiding the need to flush them on task switch. the caches provide locking on a per-line basis, allowing code and data to be permanently locked in the caches for timing-critical code. t he data cache also allows prefetching of data using the pref instruction. accesses to the instruction and data caches ar e tagged as cacheable or uncacheable on a per- page basis by the mmu. data cache writes are tagged as write-through or writeback on a per- page basis by the mmu. the data cache has a 32-byte combining write buffe r, to avoid stalling the cpu when writing to external memory. writes are tagged as bufferable or unbufferable on a per-page basis by the mmu. bufferable writes to sequential addresses are placed in the buffer, allowing for example a sequence of byte writes from the cpu to be combined into word transfers on the bus. a sync instruction is provided to explicitly flush the write buffer. 6.2.6 unaligned reference handling avr32 ap has hardware support for performing unaligned memory accesses. this will reduce the memory footprint needed by some applicatio ns, as well as speed up other applications oper- ating on unaligned data. avr32 ap is able to perform certain word-sized load and store instructions of any alignment, and word-aligned st.d and ld.d . any other unaligned memory a ccess will cause an mmu address exception. all coprocessor memory access inst ructions require word-a ligned pointers. double- word-sized accesses with word-aligned pointers will automatically be performed as two word- sized accesses. the following table shows the instructions with support for unaligned addresses. all other instructions require aligned addresses. ac cessing an unaligned address may require several clock cycles, refer to the avr32 ap technical reference manual for details. table 6-1. instructions with unaligned reference support instruction supported alignment ld.w any st.w any lddsp any lddpc any stdsp any ld.d word st.d word all coprocessor memory access instruction word
21 32054f?avr32?09/09 at32ap7002 6.2.7 unimplemented instructions the following instructions are unimplemented in avr32 ap, and will cause an unimplemented instruction exception if executed: ?mems ?memc ?memt 6.2.8 exceptions and interrupts avr32 ap incorporates a powerful exception handling scheme. the different exception sources, like illegal op-code and external interrup t requests, have different priority levels, ensur- ing a well-defined behavior when multiple except ions are received simu ltaneously. additionally, pending exceptions of a higher priority class ma y preempt handling of ongoing exceptions of a lower priority class. each priority class has dedicated registers to keep the return address and status register thereby removing the need to perform time-consuming memory operations to save this information. there are four levels of external interrupt req uests, all executing in their own context. the int3 context provides dedicated shadow registers ensuring low latency for these interrupts. an inter- rupt controller does the priority handling of th e external interrupts and provides the autovector offset to the cpu. the addresses and priority of si multaneous events are shown in table 6-2 on page 22 .
22 32054f?avr32?09/09 at32ap7002 table 6-2. priority and handler addresses for events priority handler address name event source stored return address 1 0xa000_0000 reset external input undefined 2 provided by ocd system ocd stop cpu ocd system first non-compl eted instruction 3 evba+0x00 unrecoverable exception int ernal pc of offending instruction 4 evba+0x04 tlb multiple hit internal signal pc of offending instruction 5 evba+0x08 bus error data fetch data bu s first non-completed instruction 6 evba+0x0c bus error instruction fetch dat a bus first non-completed instruction 7 evba+0x10 nmi external input first non-completed instruction 8 autovectored interrupt 3 request external input first non-completed instruction 9 autovectored interrupt 2 request external input first non-completed instruction 10 autovectored interrupt 1 request external input first non-completed instruction 11 autovectored interrupt 0 request external input first non-completed instruction 12 evba+0x14 instruction address itlb pc of offending instruction 13 evba+0x50 itlb miss itlb pc of offending instruction 14 evba+0x18 itlb protection itlb pc of offending instruction 15 evba+0x1c breakpoint ocd system firs t non-completed instruction 16 evba+0x20 illegal opcode instructio n pc of offending instruction 17 evba+0x24 unimplemented instruction instr uction pc of offending instruction 18 evba+0x28 privilege violation instruc tion pc of offending instruction 19 evba+0x2c floating-point fp hardware pc of offending instruction 20 evba+0x30 coprocessor absent instruct ion pc of offending instruction 21 evba+0x100 supervisor call instru ction pc(supervisor call) +2 22 evba+0x34 data address (read) dtlb pc of offending instruction 23 evba+0x38 data address (write) dtl b pc of offending instruction 24 evba+0x60 dtlb miss (read) dtlb pc of offending instruction 25 evba+0x70 dtlb miss (write) dtlb pc of offending instruction 26 evba+0x3c dtlb protecti on (read) dtlb pc of offending instruction 27 evba+0x40 dtlb protection (write) d tlb pc of offending instruction 28 evba+0x44 dtlb modified dtlb pc of offending instruction
23 32054f?avr32?09/09 at32ap7002 6.3 programming model 6.3.1 register file configuration the avr32b architecture specifies that the ex ception contexts may have a different number of shadowed registers in different implementations. figure 6-3 on page 23 shows the model used in avr32 ap. figure 6-3. the avr32 ap register file 6.3.2 status register configuration the status register (sr) is splitted into two halfwords, one upper and one lower, see figure 6-4 on page 23 and figure 6-5 on page 24 . the lower word contains the c, z, n, v and q condition code flags and the r, t and l bits, while the upper halfword contains information about the mode and state the processor executes in. refer to the avr32 architecture manual for details. figure 6-4. the status register high halfword application bit 0 supervisor bit 31 pc sr int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 rsr_int0 sr rsr_ex sr sp_app sp_sys rsr_nmi sr r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc fintpc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc lr_int3 r12_int3 r11_int3 r9_int3 r10_int3 r8_int3 sp_sys sp_sys sp_sys r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 sp_sys r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 sp_sys r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 sp_sys r12 r11 r9 r10 r8 rsr_int1 sr rsr_int2 sr rsr_int3 sr int0 int1 int2 int3 exception nmi fintpc smpc r7 r5 r6 r4 r3 r1 r2 r0 r12 r11 r9 r10 r8 lr lr lr lr lr lr lr rsr_sup rar_int0 rar_ex rar_nmi rar_int1 rar_int2 rar_int3 rar_sup bit 31 0 0 0 bit 16 interrupt level 0 mask interrupt level 1 mask interrupt level 3 mask interrupt level 2 mask 1 0 0 0 0 1 1 0 0 0 0 0 0 reserved fe i0m gm m1 j d m0 em i2m dm - m2 lc 1 - initial value bit name i1m mode bit 0 mode bit 1 h mode bit 2 reserved debug state - i3m java state exception mask global interrupt mask debug state mask java handle reserved
24 32054f?avr32?09/09 at32ap7002 figure 6-5. the status register low halfword 6.3.3 processor states 6.3.3.1 normal risc state the avr32 processor supports several diff erent execution contexts as shown in table 6-3 on page 24 . mode changes can be made under software control, or can be caused by external interrupts or exception processing. a mode can be interrupted by a higher priority mode, but never by one with lower priority. nested exceptions can be supported with a minimal software overhead. when running an operating syste m on the avr32, user processes will typically execute in the application mode. the programs executed in this mode are restricted from executing certain instructions. furthermore, most system registers together with the upper halfword of the status register cannot be accessed. protected memory areas are also not available. all other operating modes are privileged and are collectively called system modes. they have full access to all priv- ileged and unprivileged re sources. after a reset, the proc essor will be in su pervisor mode. 6.3.3.2 debug state the avr32 can be set in a debug state, which allows implementation of software monitor rou- tines that can read out and alter system information for use during application development. this implies that all system and application regist ers, including the status registers and program counters, are accessible in debug state. th e privileged instructions are also available. bit 15 bit 0 reserved carry zero sign 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - t r bit name initial value 0 0 l q v n z c - overflow saturation - - - lock register remap enable scratch table 6-3. overview of execution modes, their priorities and pr ivilege levels. priority mode securi ty description 1 non maskable interrupt privileged non maskable high priority interrupt mode 2 exception privileged execute exceptions 3 interrupt 3 privileged general purpose interrupt mode 4 interrupt 2 privileged general purpose interrupt mode 5 interrupt 1 privileged general purpose interrupt mode 6 interrupt 0 privileged general purpose interrupt mode n/a supervisor privileged runs supervisor calls n/a application unprivileged normal program execution mode
25 32054f?avr32?09/09 at32ap7002 all interrupt levels are by default disabled when debug state is entered, but they can individually be switched on by the monitor routine by clearing the respective mask bit in the status register. debug state can be entered as described in the avr32 ap technical reference manual . debug state is exited by the retd instruction. 6.3.3.3 java state avr32 ap implements a java extension module (jem). the processor can be set in a java state where normal risc operations are suspended. refer to the avr32 java technical refer- ence manual for details.
26 32054f?avr32?09/09 at32ap7002 7. pixel coprocessor (pico) rev.: 1.0.0.0 7.1 features ? coprocessor coupled to the avr3 2 cpu core through the tcb bus. ? three parallel vector multiplicati on units (vmu) where each unit can: ? multiply three pixel componen ts with three coefficients. ? add the products from the multiplications together. ? accumulate the result or add an o ffset to the sum of the products. ? can be used for accelerating: ? image color space conversion. ?configurable conver sion coefficients. ? supports packed and planar input and output formats. ? supports subsampled input color spaces (i.e 4:2:2, 4:2:0). ? image filtering/scaling. ? configurable filter coefficients. ? throughput of one sample per cycle for a 9-tap fir filter. ? can use the built-in accumulator to extend the fir filter to more than 9-taps. ? can be used for bilinear/bicubic interpolations. ? mpeg-4/h.264 quarter pi xel motion compensation. ? flexible input pixel selector. ? can operate on numerous different image storage formats. ? flexible output pixel inserter. ? scales and saturates the results back to 8-bit pixel values. ? supports packed and planar output formats. ? configurable coefficien ts with flexible fixe d-point representation. 7.2 description the pixel coprocessor (pico) is a coprocessor coupled to the avr32 cpu through the tcb (tightly coupled bus) interface. the pico cons ists of three vector multiplication units (vmu0, vmu1, vmu2), an input pixel selector and an output pixel inserter. each vmu can perform a vector multiplication of a 1x3 12-bit coefficient vector with a 3x1 8-bit pixel vector. in addition a 12-bit offset can be added to the result of this vector multiplication. the pico can be used for transforming the pixe l components in a given color space (i.e. rgb, ycrcb, yuv) to any othe r color space as long as the transformation is linear. the flexibility of the input pixel selector and output pixel insertio n logic makes it easy to efficiently support dif- ferent pixel storage formats with regards to issues such as byte ordering of the color components, if the color components constituting an image are packed/interleaved or stored as separate images or if any of the color components are subsampled. the three vector multiplication units can also be connected together to form one large vector multiplier which can perform a vector multiplication of a 1x9 12-bit coefficient vector with a 9x1 8- bit pixel vector. this can be used to implement fir filters, bilinear interpolations filters for smoothing/scaling images etc. by allowing the outputs from the vector multiplication units to accumulate it is also possible to extend the order of the filter to more than 9-taps. the results from the vmus are scaled and saturated back to unsigned 8-bit pixel values in the output pixel inserter.
27 32054f?avr32?09/09 at32ap7002 the pico is divided into three pipeline stages with a throughput of one operation per cpu clock cycle. 7.3 block diagram figure 7-1. pixel coprocessor block diagram inpix0 vmu0_out input pixel selector vmu0 add vmu0_in0 vmu0_in1 vmu0_in2 inpix1 inpix2 coeff0_0 coeff0_1 coeff0_2 offset0 vmu1_out vmu1 vmu1_in0 vmu1_in1 vmu1_in2 coeff1_0 coeff1_1 coeff1_2 offset1 vmu2_out vmu2 vmu2_in0 vmu2_in1 vmu2_in2 coeff2_0 coeff2_1 coeff2_2 offset2 outpix0 outpix1 outpix2 output pixel inserter pipeline stage 1 pipeline stage 2 pipeline stage 3
28 32054f?avr32?09/09 at32ap7002 7.4 vector multiplication unit (vmu) each vmu consists of three mult ipliers used for multiplying uns igned 8-bit pixel components with signed 12-bit coefficients.the result from each multiplication is a 20-bit signed number that is input to a 22-bit vector adder along with an offset as shown in figure 7-2 on page 28 . the oper- ation is equal to the offsetted vector multiplication given in the following equation: figure 7-2. inside vmu n ( n {0,1,2}) 7.5 input pixel selector the input pixel selector uses the ism (input selection mode) field in the config register and the three input pixel source addresses given in the pico operation instructions to decide which pixels to select for inputs to the vmus. 7.5.1 transformation mode when the input selection mode is set to transformation mode the input pixel source addresses inx, iny and inz directly maps to three pixels in the inpix n registers. these three pixels are then input to each of the vmus. the following expression then represents what is computed by the vmus in transformation mode: 7.5.2 horizontal filter mode in horizontal filter mode the input pixel source addresses inx, iny and inz represents the base pixel address of a pixel triplet. the pixel triplet {in(x), in(x+1), in(x+2)} is input to vmu0, the pixel triplet {in(y), in(y+1), in(y+2 )} is input to vmu1 and the pixe l triplet {in(z), in(z+1), in(z+2)} vmu_out coeff0 coeff1 coeff2 vmu_in0 vmu_in1 vmu_in2 offset + = multiply vector adder multiply multiply vmu n offset n coeff n _1 coeff n _2 coeff n _0 vmu n _in0 vmu n _in1 vmu n _in2 vmu n _out vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz offset0 or vmu0_out offset1 or vmu1_out offset2 or vmu2_out + =
29 32054f?avr32?09/09 at32ap7002 is input to vmu2. figure 7-3 on page 29 shows how the pixel triplet is found by taking the pixel addressed by the base address and following the arrow to find the next two pixels which makes up the triplet. figure 7-3. horizontal filter mode pixel addressing the following expression represents what is computed by the vmus in horizontal filter mode: 7.5.3 vertical filter mode in vertical filter mode the input pixel source addresses inx, iny and inz represent the base of a pixel triplet found by following the vertical arrow shown in figure 7-4 on page 29 . the pixel triplet {in(x), in((x+4)%11), in((x+8)%11)} is input to vmu0, the pixel triplet {in(y), in((y+4)%11), in((y+8)%11)} is input to vmu1 and the pixel trip let {in(z), in((z+4)%11), in((z+8)%11)} is input to vmu2. figure 7-4. vertical filter mode pixel addressing inpix0 in0 in1 in2 in3 in4 in5 in6 in7 in8 in9 in10 in11 inpix1 inpix2 vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) offset0 or vmu0_out () + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) offset1 or vmu1_out () + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) offset2 or vmu2_out () + = inpix0 in0 in1 in2 in3 in4 in5 in6 in7 in8 in9 in10 in11 inpix1 inpix2
30 32054f?avr32?09/09 at32ap7002 the following expression represents what is computed by the vmus in vertical filter mode: 7.6 output pixel inserter the output pixel inserter uses the oim (output insertion mode) field in the config register and the destination pixel address given in the pico operation instructions to decide which three of the twelve possible out n pixels to write back the scaled a nd saturated results from the vmus to. the 22-bit results from each vmu is first scal ed by performing an arithmetical right shift by coeff_frac_bits in order to remove the fractional part of the results and obtain the integer part. the integer part is then saturated to an unsigned 8-bit number in the range 0 to 255. 7.6.1 planar insertion mode in planar insertion mode the destination pixel address outd specifies which pixel in each of the registers outpix0, outpix1 and outpix2 will be updated. vmu n writes to outpix n . this can be seen in figure 7-5 on page 30 and table 7-2 on page 48 . this mode is useful when transforming from one color space to another where the resulting color components should be stored in separate images. figure 7-5. planar pixel insertion vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) offset0 or vmu0_out () + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) offset1 or vmu1_out () + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) offset2 or vmu2_out () + = outpix0 out0 out1 out2 out3 out4 out5 out6 out7 out8 out9 out10 out11 outpix1 outpix2 d = 0 d = 2 d = 1 d = 3 = vmu0 = vmu1 = vmu2
31 32054f?avr32?09/09 at32ap7002 7.6.2 packed insertion mode in packed insertion mode the three output registers outpix0, outpix1 and outpix2 are divided into four pixel triplets as seen in figure 7-6 on page 31 and table 7-2 on page 48 . the destination pixel address is then the address of the pixel triplet. vmu n writes to pixel n of the pixel triplet.this mode is useful when transfo rming from one color space to another where the resulting color components sh ould be packed together. figure 7-6. packed pixel insertion. outpix0 out0 out1 out2 out3 out4 out5 out6 out7 out8 out9 out10 out11 d = 0 d = 1 d = 2 d = 3 outpix1 outpix2 = vmu0 = vmu1 = vmu2
32 32054f?avr32?09/09 at32ap7002 7.7 user interface the pico uses the tcb interface to communicate with the cpu and the user can read from or write to the pico register file by using the pico load/store/move instructions which maps to generic coprocessor instructions. 7.7.1 register file the pico register file can be accessed from the cpu by using the picomv.x, picold.x, picost.x, picoldm and picostm instructions. table 7-1. pico register file cp reg # register name access cr0 input pixel register 2 inpix2 read/write cr1 input pixel register 1 inpix1 read/write cr2 input pixel register 0 inpix0 read/write cr3 output pixel register 2 outpix2 read only cr4 output pixel register 1 outpix1 read only cr5 output pixel register 0 outpix0 read only cr6 coefficient register a for vmu0 coeff0_a read/write cr7 coefficient register b for vmu0 coeff0_b read/write cr8 coefficient register a for vmu1 coeff1_a read/write cr9 coefficient register b for vmu1 coeff1_b read/write cr10 coefficient register a for vmu2 coeff2_a read/write cr11 coefficient register b for vmu2 coeff2_b read/write cr12 output from vmu0 vmu0_out read/write cr13 output from vmu1 vmu1_out read/write cr14 output from vmu2 vmu2_out read/write cr15 pico configuration register config read/write
33 32054f?avr32?09/09 at32ap7002 7.7.1.1 input pixel register 0 register name: inpix0 access type: read/write ? in0: input pixel 0 input pixel number 0 to the input pixel selector unit. ? in1: input pixel 1 input pixel number 1 to the input pixel selector unit. ? in2: input pixel 2 input pixel number 2 to the input pixel selector unit. ? in3: input pixel 3 input pixel number 3 to the input pixel selector unit. 31 30 29 28 27 26 25 24 in0 23 22 21 20 19 18 17 16 in1 15 14 13 12 11 10 9 8 in2 76543210 in3
34 32054f?avr32?09/09 at32ap7002 7.7.1.2 input pixel register 1 register name: inpix1 access type: read/write ? in0: input pixel 4 input pixel number 4 to the input pixel selector unit. ? in1: input pixel 5 input pixel number 5 to the input pixel selector unit. ? in2: input pixel 6 input pixel number 6 to the input pixel selector unit. ? in3: input pixel 7 input pixel number 7 to the input pixel selector unit. 31 30 29 28 27 26 25 24 in4 23 22 21 20 19 18 17 16 in5 15 14 13 12 11 10 9 8 in6 76543210 in7
35 32054f?avr32?09/09 at32ap7002 7.7.1.3 input pixel register 2 register name: inpix2 access type: read/write ? in0: input pixel 8 input pixel number 8 to the input pixel selector unit. ? in1: input pixel 9 input pixel number 9 to the input pixel selector unit. ? in2: input pixel 10 input pixel number 10 to the input pixel selector unit. ? in3: input pixel 11 input pixel number 11 to the input pixel selector unit. 31 30 29 28 27 26 25 24 in8 23 22 21 20 19 18 17 16 in9 15 14 13 12 11 10 9 8 in10 76543210 in11
36 32054f?avr32?09/09 at32ap7002 7.7.1.4 output pixel register 0 register name: outpix0 access type: read ? out0: output pixel 0 output pixel number 0 from the output pixel inserter unit. ? out1: output pixel 1 output pixel number 1 from the output pixel inserter unit. ? out2: output pixel 2 output pixel number 2 from the output pixel inserter unit. ? out3: output pixel 3 output pixel number 3 from the output pixel inserter unit. 31 30 29 28 27 26 25 24 out0 23 22 21 20 19 18 17 16 out1 15 14 13 12 11 10 9 8 out2 76543210 out3
37 32054f?avr32?09/09 at32ap7002 7.7.1.5 output pixel register 1 register name: outpix1 access type: read ? out4: output pixel 4 output pixel number 4 from the output pixel inserter unit. ? out5: output pixel 5 output pixel number 5 from the output pixel inserter unit. ? out6: output pixel 6 output pixel number 6 from the output pixel inserter unit. ? out7: output pixel 7 output pixel number 7 from the output pixel inserter unit. 31 30 29 28 27 26 25 24 out4 23 22 21 20 19 18 17 16 out5 15 14 13 12 11 10 9 8 out6 76543210 out7
38 32054f?avr32?09/09 at32ap7002 7.7.1.6 output pixel register 2 register name: outpix2 access type: read ? out8: output pixel 8 output pixel number 8 from the output pixel inserter unit. ? out9: output pixel 9 output pixel number 9 from the output pixel inserter unit. ? out10: output pixel 10 output pixel number 10 from the output pixel inserter unit. ? out11: output pixel 11 output pixel number 11 from the output pixel inserter unit. 31 30 29 28 27 26 25 24 out8 23 22 21 20 19 18 17 16 out9 15 14 13 12 11 10 9 8 out10 76543210 out11
39 32054f?avr32?09/09 at32ap7002 7.7.1.7 coefficient register a for vmu0 register name: coeff0_a access type: read/write ? coeff0_0: coefficient 0 for vmu0 coefficient 0 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff0_0 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff0_0 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? coeff0_1: coefficient 1 for vmu0 coefficient 1 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff0_1 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff0_1 is sign- extended to 16-bits in or der to fill in the unused bits in th e lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff0_0 23 22 21 20 19 18 17 16 coeff0_0 15 14 13 12 11 10 9 8 ---- coeff0_1 76543210 coeff0_1 coeff0_0 2 coeff_frac_bits ? ?
40 32054f?avr32?09/09 at32ap7002 7.7.1.8 coefficient register b for vmu0 register name: coeff0_b access type: read/write ? coeff0_2: coefficient 2 for vmu0 coefficient 2 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff0_2 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff0_2 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? offset0: offset for vmu0 offset input to vmu0 in case of non-accumulating operations. a signed 12-bit fixed-point number where the number of frac- tional bits is given by the offset_fra c_bits field in the config register. t he actual fractional number is equal to , where the offset0 value is interpreted as a 2?s complement integer. when reading this reg- ister, offset0 is sign-extended to 16-bits in order to fill in the unused bits in the lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff0_2 23 22 21 20 19 18 17 16 coeff0_2 15 14 13 12 11 10 9 8 ---- offset0 76543210 offset0 coeff0_2 2 coeff_frac_bits ? ?
41 32054f?avr32?09/09 at32ap7002 7.7.1.9 coefficient register a for vmu1 register name: coeff1_a access type: read/write ? coeff1_0: coefficient 0 for vmu1 coefficient 0 input to vmu1. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff1_0 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff1_0 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? coeff1_1: coefficient 1 for vmu1 coefficient 1 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff1_1 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff1_1 is sign- extended to 16-bits in or der to fill in the unused bits in th e lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff1_0 23 22 21 20 19 18 17 16 coeff1_0 15 14 13 12 11 10 9 8 ---- coeff1_1 76543210 coeff1_1 coeff1_0 2 coeff_frac_bits ? ?
42 32054f?avr32?09/09 at32ap7002 7.7.1.10 coefficient register b for vmu1 register name: coeff1_b access type: read/write ? coeff1_2: coefficient 2 for vmu1 coefficient 2 input to vmu1. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff1_2 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff1_2 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? offset1: offset for vmu1 offset input to vmu1 in case of non-accumulating operations. a signed 12-bit fixed-point number where the number of frac- tional bits is given by the offset_fra c_bits field in the config register. t he actual fractional number is equal to , where the offset1 value is interpreted as a 2?s complement integer. when reading this reg- ister, offset1 is sign-extended to 16-bits in order to fill in the unused bits in the lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff1_2 23 22 21 20 19 18 17 16 coeff1_2 15 14 13 12 11 10 9 8 ---- offset1 76543210 offset1 coeff1_2 2 coeff_frac_bits ? ?
43 32054f?avr32?09/09 at32ap7002 7.7.1.11 coefficient register a for vmu2 register name: coeff2_a access type: read/write ? coeff2_0: coefficient 0 for vmu2 coefficient 0 input to vmu2. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff2_0 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff2_0 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? coeff2_1: coefficient 1 for vmu2 coefficient 1 input to vmu2. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff2_1 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff2_1 is sign- extended to 16-bits in or der to fill in the unused bits in th e lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff2_0 23 22 21 20 19 18 17 16 coeff2_0 15 14 13 12 11 10 9 8 ---- coeff2_1 76543210 coeff2_1 coeff2_0 2 coeff_frac_bits ? ?
44 32054f?avr32?09/09 at32ap7002 7.7.1.12 coefficient register b for vmu2 register name: coeff2_b access type: read/write ? coeff2_2: coefficient 2 for vmu2 coefficient 2 input to vmu2. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff2_2 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff2_2 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? offset2: offset for vmu2 offset input to vmu2 in case of non-accumulating operations. a signed 12-bit fixed-point number where the number of frac- tional bits is given by the offset_fra c_bits field in the config register. t he actual fractional number is equal to , where the offset2 value is interpreted as a 2?s complement integer. when reading this reg- ister, offset2 is sign-extended to 16-bits in order to fill in the unused bits in the lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff2_2 23 22 21 20 19 18 17 16 coeff2_2 15 14 13 12 11 10 9 8 ---- offset2 76543210 offset2 coeff2_2 2 coeff_frac_bits ? ?
45 32054f?avr32?09/09 at32ap7002 7.7.1.13 vmu0 output register register name: vmu0_out access type: read/write ? vmu0_out: output from vmu0 this register is used for directly accessing the output from vmu0 or for setting the initial value of the accumulator for accu- mulating operations. the output from vmu0 is a signed 22-bit fixed-point number where the number of fractional bits are given by the coeff_frac_bits field in the config register. wh en reading this register the signed 22-bit value is sign- extended to 32-bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - vmu0_out 15 14 13 12 11 10 9 8 vmu0_out 76543210 vmu0_out
46 32054f?avr32?09/09 at32ap7002 7.7.1.14 vmu1 output register register name: vmu1_out access type: read/write ? vmu1_out: output from vmu1 this register is used for directly accessing the output from vmu1 or for setting the initial value of the accumulator for accu- mulating operations. the output from vmu1 is a signed 22-bit fixed-point number where the number of fractional bits are given by the coeff_frac_bits field in the config register. wh en reading this register the signed 22-bit value is sign- extended to 32-bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - vmu1_out 15 14 13 12 11 10 9 8 vmu1_out 76543210 vmu1_out
47 32054f?avr32?09/09 at32ap7002 7.7.1.15 vmu2 output register register name: vmu2_out access type: read/write ? vmu2_out: output from vmu2 this register is used for directly accessing the output from vmu2 or for setting the initial value of the accumulator for accu- mulating operations. the output from vmu2 is a signed 22-bit fixed-point number where the number of fractional bits are given by the coeff_frac_bits field in the config register. wh en reading this register the signed 22-bit value is sign- extended to 32-bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - vmu2_out 15 14 13 12 11 10 9 8 vmu2_out 76543210 vmu2_out
48 32054f?avr32?09/09 at32ap7002 7.7.1.16 pico configuration register register name: config access type: read/write ? oim: output insertion mode the oim bit specifies the semantics of the outd output pixel address parameter to the pico(s)v(mul/mac) instructions. the oim together with the output pixel address parameter specify which of the 12 output bytes (out n ) of the outpix n regis- ters will be updated with th e results from the vmus. table 7-2 on page 48 describes the different output insertion modes. see section 7.6 ?output pixel inserter? on page 30 for a description of the output pixel inserter. ? ism: input selection mode the ism field specifies the semantics of the input pixel address parameters inx, iny and inz to the pico(s)v(mul/mac) instructions. together with the three input pixel addresses the ism field specifies to the input pixel selector which of th e input pixels (in n ) that should be selected as inputs to the vmus. table 7-3 on page 49 describes the 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----oim ism 76543210 offset_frac_bits coeff_frac_bits table 7-2. output insertion modes oim mode description 0 packed insertion mode {outpix0, outpix1, outpix2} is treated as one large register containing 4 sequential 24- bit pixel triplets. the dst_adr field specifies wh ich of the sequential triplets will be updated. out(d*3 + 0) scaled and saturated output from vmu0 out(d*3 + 1) scaled and saturated output from vmu1 out(d*3 + 2) scaled and saturated output from vmu2 1 planar insertion mode each of the outpix n registers will get one of the resulting pixels. the triplet address specifies what byte in each of the outpix n registers the results will be written to. out(d + 0) scaled and saturated output from vmu0 out(d+ 4) scaled and saturated output from vmu1 out(d + 8) scaled and saturated output from vmu2
49 32054f?avr32?09/09 at32ap7002 different input selection modes. see section 7.5 ?input pixel selector? on page 28 for a description of the input pixel selector. ? offset_frac_bits: offset fractional bits specifies the number of fractional bits in the fixed-point offsets input to each vmu. must be in the range from 0 to coeff_frac_bits. other values gives undefined resu lts.this value is used for scaling the offset n values before being input to vmu n so that the offset will have the same fixed-point format as the outputs from the multiplication stages before performing the vector addition in the vmu. ? coeff_frac_bits: coefficient fractional bits specifies the number of fractional bits in the fixed-point coefficients input to each vmu. must be in the range from 0 to 11, since at least one bit of the coefficient must be us ed for the sign. other values gives undefined results. coeff_frac_bits is used in the output pixel inserter to sc ale the fixed-point results from the vmus back to unsigned 8- bit integers. table 7-3. input selection modes ism mode 0 0 transformation mode vmu0, vmu1 and vmu2 get the same pixel inputs. these three pixels can be freely selected from the inpix n registers. 0 1 horizontal filter mode pixel triplets are selected for input to each of the vmus by addressing horizontal pixel triplets from the inpix n registers. 1 0 vertical filter mode pixel triplets are selected for input to each of the vmus by addressing vertical pixel triplets from the inpix n registers. 1 1 reserved n.a
50 32054f?avr32?09/09 at32ap7002 7.8 pico instructions 7.8.1 pico instructions nomenclature 7.8.1.1 registers and operands r {d, s, ?} the uppercase ? r ? denotes a 32-bit (word) register. r d the lowercase ? d ? denotes the destination register number. r s the lowercase ? s ? denotes the source register number. r b the lowercase ? b ? denotes the base register number for indexed addressing modes. r i the lowercase ? i ? denotes the index register number for indexed addressing modes. r p the lowercase ? p ? denotes the pointer register number. in {x, y, z} the uppercase ? in ? denotes a pixel in the inpix n registers. in x the lowercase ? x ? denotes the first input pixel number for the pico operation instructions. in y the lowercase ? y ? denotes the second input pixel number for the pico operation instructions. in z the lowercase ? z ? denotes the third input pixel number for the pico operation instructions. out d the uppercase ? out ? denotes a pixel in the outpix n registers. out d the lowercase ? d ? denotes the destination pixel number for the pico operation instructions. pr pico register. see section 7.7.1 ?register file? on page 32 for a complete list of registers. prhi:prlo pico register pair. only register pairs corres ponding to valid coprocessor double registers are valid. e.g. inpix1:inpix2 (cr1:cr0). the low part must correspond to an even coprocessor register number n and the high part must then correspond to coprocessor register n+1 . see table 7-1 on page 32 for a mapping between pico register names and coprocessor register numbers. pc program counter, equal to r15 lr link register, equal to r14 sp stack pointer, equal to r13 picoreglist register list used in the picoldm and picostm instructions. see instruct ion description for which register combinations are allowed in the register list. disp displacement sa shift amount [i] denotes bit i in a immediate value. example: imm6[4] denotes bit 4 in an 6-bit immediate value. [i:j] denotes bit i to j in an immediate value. some instructions access or use doubleword operands. these operands must be placed in two consecutive register addresses where the first register must be an even register . the even register contains the least significant part and the odd register contains the most significant part. this ordering is reversed in comparison with how data is organized in memory (where the most significant part would receive the lowest address) and is intentional.
51 32054f?avr32?09/09 at32ap7002 the programmer is responsible for placing these operands in properly aligned register pairs. this is also specified in the "operands" section in the detailed de scription of each instruct ion. failure to do so will result in an undefined behavior. 7.8.1.2 operations asr(x, n) se(x, bits(x) + n) >> n satsu(x, n) signed to unsigned saturation ( x is treated as a signed value ): if (x > (2 n -1)) then (2 n-1 -1); elseif ( x < 0 ) then 0; else x; se(x, n) sign extend x to an n-bit value 7.8.1.3 data type extensions .d double (64-bit) operation. .w word (32-bit) operation.
52 32054f?avr32?09/09 at32ap7002 7.8.2 pico instruction summary table 7-4. pico instruction summary mnemonics operands / syntax description operation picosvmac e outd, inx, iny, inz pico single vector multiplication and accumulation. see pico instruction set reference picosvmul e outd, inx, iny, inz pic o single vector multiplication see pico instruction set reference picovmac e outd, inx, iny, inz pico vector multiplications and accumulations. see pico instruction set reference picovmul e outd, inx, iny, inz pico vector mult iplications. see pico instruction set reference picold.d e prhi:prlo, rp[disp] load pico register pair prhi:prlo *(rp+ze(disp8<<2)) e prhi:prlo, --rp load pico register pair with pre-decrement prhi:prlo *(--rp) e prhi:prlo, rb[ri< 53 32054f?avr32?09/09 at32ap7002 picosvmac ? pico singl e vector multiplication and accumulation description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the values in the vmu n _out registers are then accumulated with the new results from the vector mult iplications. the results from each vector multiplication unit (vmu) are then added together for one of the outputs to the output pixels inserter to form the result of a single vector multiplication of two 9-ele - ment vectors. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out + vmu1_out + vmu2_out, coeff_frac_bits) , 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out + vmu1_out+ vmu2_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) vmu2_out + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) vmu2_out + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz vmu0_out vmu1_out vmu2_out + =
54 32054f?avr32?09/09 at32ap7002 syntax: i. picosvmac outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ..., 11} opcode: example: /* inner loop of a 16-tap symmetric fir filter with coefficients {c0, c1, c2, c3, c4, c5 , c6, c7, c7, ..., c0} set to filter the pixels pointed to by r12 storing the result to the memory poi nted to by r11. the coeffici ents in the pico are already set to the following values: coeff0_0 = c0, coeff0_1 = c1, coeff0_2 = c2, coeff1_0 = c3, coeff1_1 = c4, coeff1_2 = c5, coeff2_0 = c6, coeff2_1 = c7, coeff 2_2 = 0, offset0 = 0.5 (for rounding the result), offset1 = 0, offset2 = 0. the input selection mode is set to horizontal filter mode while the output insertion mode is set to planar insertion mode. the input image pointer might be unaligned, hence the use of ld.w instead of picold.w. */ ... ld.w r1, r12[0] /* r1 = *((int *)src) */ ld.w r0, r12[4] /* r0 = *(((int *)src) + 1) */ ld.w r2, r12[8] /* r2 = *(((int *)src) + 2) */ ld.w r3, r12[12] /* r3 = *(((int *)src) + 3) */ picomv.d inpix1:inpix2, r0 /* inpix1={src[0],src[1],sr c[2],src[3]}, inpix2={src[4],src[5],src[6],src[7]}*/ swap.b r2 /* r2 = {src[11],src[10],src[9],src[8]}*/ swap.b r3 /* r3 = {src[15],src[14],src[13],src[12]}*/ picosvmul out3, in4, in7, in10 /* vmu0_o ut = c0*src[0]+c1*src[1]+c2*src[2] + 0.5 vmu1_out = c3*src[3]+c4*src[4]+c5*src[5] vmu2_out = c6*src[6]+c7*src[7] */ picomv.d inpix1:inpix2, r2 /* inpix1 ={src[15],src[14], src[13],src[12]}, inpix2 ={src[11],src[ 10],src[9],src[8]} */ picosvmac out3, in4, in7, in10 /* vmu0_o ut += c0*src[15]+c1*src[14]+c2*src[13] vmu1_out += c3*src[12]+c4*src[11]+c5*src[10] vmu2_out += c6*src[9]+c7*src[8] out3 = satscaled(vmu0_out+vmu1_out+vmu2_out)*/ sub r12, -1 /* src++ */ picomv.w r4, outpix0 /* r4 = { out0, out1, out2, out3 } st.b r11++, r4 /* *dst = out3 */ ... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010011 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
55 32054f?avr32?09/09 at32ap7002 picosvmul ? pico single vector multiplication description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the results from each vector multiplication unit (vmu) are then added together for one of the outputs to the output pixels inserter to form the result of a single vector multiplication of two 9-element vectors. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. offset_scale = coeff_fr ac_bits - offset_frac_bits if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out + vmu1_out + vmu2_out, coeff_frac_bits), 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out + vmu1_out+ vmu2_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) offset2 << offset_scale + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) offset2 << offset_scale + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz offset0 << offset_scale offset1 << offset_scale offse20 << offset_scale + =
56 32054f?avr32?09/09 at32ap7002 syntax: i. picosvmul outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ... , 11} opcode: example: /* excerpt from inner loop of bilinear interpolation filter op erating on image component stor ed in an array pointed to by r12. the width of the image is stored in r11 while the result ing filtered image is pointed to by r10. the coefficients of the filter: a, b, c, d are already set before this code is executed. coeff0 _0 = a, coeff0_1 = b, coeff0_2 = 0, coeff1_0 = c, coeff1_1 = d, coeff1_2 = 0, coeff2_0 = 0, coeff2_1 = 0, coeff2_2 = 0, offset0 = 0.5 (for rounding the result), offset1 = 0, offset2 = 0. the input selection mode is set to horizontal filter mode while the output insertion mode is set to planar insertion mode. the input image pointer might be unaligned, hence the use of ld.w instead of picold.w, while the output image pointer is word aligned. four output pixels are computed in th is example which show an example of a bilinear inte rpolation filter found in the motion compensation used in the h.264 video standard. */ ... ld.w r1, r12[0] /* r1 = *((int *)src) */ ld.w r0, r12[r11] /* r0 = *((int *)(src + width)) */ sub r12, -2 /* src+=2 */ ld.w r3, r12[0] /* r3 = *((int *)src) */ ld.w r2, r12[r11] /* r2 = *((int *)(src + width)) */ picomv.d inpix1:inpix2, r0 /* inpix1 = r1, inpix2 = r0 */ picosvmul out0, in4, in8, in0 /* out0 = a*src[j][i+0] + b*src[j][i+1] c*src[j+1][i] + d*src[j+1][i+1] */ picosvmul out1, in5, in9, in0 /* out1 = a*src[j][i+1 ] + b*src[j][i+2] c*src[j+1] [i+1] + d*src[j+1][i+2] */ picomv.d inpix1:inpix2, r2 /* inpix1 = r3, inpix2 = r2 */ picosvmul out2, in4, in8, in0 /* out2 = a*src[j][i+2 ] + b*src[j][i+3] c*src[j+1] [i+2] + d*src[j+1][i+3] */ picosvmul out3, in5, in9, in0 /* out3 = a*src[j][i+3 ] + b*src[j][i+4] c*src[j+1] [i+3] + d*src[j+1][i+4] */ sub r12, -2 /* src+=2 */ picost.w r10++, outpix0 /* *((int *)src) = { out0, out1, out2, out3 } */ ... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010010 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
57 32054f?avr32?09/09 at32ap7002 picovmac ? pico vector mu ltiplication and accumulation description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the values in the vmu n _out registers are then accumulated with the new results from the vector multiplications. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) vmu2_out + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) vmu2_out + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz vmu0_out vmu1_out vmu2_out + =
58 32054f?avr32?09/09 at32ap7002 syntax: i. picovmac outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ... , 11} opcode: example: /* inner loop of a 6-tap symmetric fir filter with coefficients {c0, c1, c2, c2, c1, c0 } set to filter in the vertical direction of the image pointed to by r12 with the width of the image stored in r11 and the destinat ion image stored in r10. the coefficients in the pico are already set to the following values: coeff0_0 = c0, coeff0_1 = c1, coeff0_2 = c2, coeff1_0 = c0, coeff1_1 = c1, coeff1_2 = c2, coeff2_0 = c0, coeff2_1 = c1, coeff2_2 = c2, offset0 = offset1 = offset2 = 0.5 (for rounding the result). the input selection mode is set to vertical filter mode wh ile the output insertion mode is set to packed insertion mode. the input image is assumed to be word aligned. */ ... picold.w inpix0, r12[0] /* inpix0 = {src[0][0], src[0][1], src[0][2], src[0][3] }*/ picold.w inpix1, r12[r11] /* inpix1 = {src[1][0], src[1][1], src[1][2], src[1][3] }*/ picold.w inpix2, r12[r11 << 1] /* inpix2 = {src[2][0], src[2][1], src[2][2], src[2][3] }*/ add r9, r12, r11 /* r9 = src + width */ picovmul out0, in0, in1, in2 /* vmu0_out = c 0*src[0][0]+c1*src[1][0]+c2*src[2][0] + 0.5 vmu1_out = c0*src[0][1]+c1* src[1][1]+c2*src[2][1] + 0.5 vmu2_out = c0*src[0][2]+c1*sr c[1][2]+c2*src[2][2] + 0.5*/ picold.w inpix2, r9[r11 << 1] /* inpix2 = {src[3][0], src[3][1], src[3][2], src[3][3] }*/ picold.w inpix1, r12[r11 << 2] /* inpix1 = {src[4][0], src[4][1], src[4][2], src[4][3] }*/ picold.w inpix0, r9[r11 << 2] /* inpix0 = {src[5][0], src[5][1], src[5][2], src[5][3] }*/ picovmac out0, in0, in1, in2 /* vmu0_out += c0*src[5][0]+c1*src[4][0]+c2*src[3][0] vmu1_out += c0*src[5][1]+c1*src[4][1]+c2*src[3][1] vmu2_out += c0*src[5][2]+c1*src[4][2]+c2*src[3][2] out0 = satscale(vmu0_out), out1 = satscale(vmu1_out), out2 = satscale(vmu2_out) */ .... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010001 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
59 32054f?avr32?09/09 at32ap7002 picovmul ? pico v ector multiplication description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. offset_scale = coeff_fr ac_bits - offset_frac_bits if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) offset2 << offset_scale + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) offset2 << offset_scale + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz offset0 << offset_scale offset1 << offset_scale offse20 << offset_scale + =
60 32054f?avr32?09/09 at32ap7002 syntax: i. picovmul outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ... , 11} opcode: example: /* excerpt from inner loop of ycrcb 4:2:2 planar format to rgb packed format image colo r conversion. the coefficients of the transform is already set before this code is executed. in transforms like this, the inputs y, cr and cb are often offsetted with a given amount. this offset can be factored out and included in the offsets like this: 1.164*(y - 16) = 1.164*y - 18.625. the pointer to the y component is in r12, the pointer to the cr component in r11 and the pointer to the cb component in r10. the pointer to the rgb output image is in r9. the input selection mode is set to transform mode while the output insertion mode is set to packed insertion mode. it is assumed that all the input and output pointers are word aligned. four rgb triplets are com puted in this example. */ ... picold.w inpix0, r12++ /* inpix0= { y[0], y[1], y[ 2], y[3] }*/ picold.w inpix1, r11++ /* inpix1= { cr[0], cr[1], cr[2], cr[3] }*/ picold.w inpix2, r10++ /* inpix2= { cb[0], cb[1], cb[2], cb[3] }*/ picovmul out0, in0, in4, in8 /* out0 = r[0], out1 = g[0], out2 = b[0] */ picovmul out1, in1, in4, in8 /* out3 = r[1], out4 = g[1], out5 = b[1] */ picovmul out2, in2, in5, in9 /* out6 = r[2], out7 = g[2], out8 = b[2] */ picovmul out3, in3, in5, in9 /* out9 = r[3], out10 = g[3], out11 = b[3] */ picostm r9, outpix2, outpix1, outpix0/* rgb = {r[0],g[ 0],b[0],r[1],g[1],b[1],r[2],g[2],b[2],r[3],g[3],b[3]} */ ... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010000 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
61 32054f?avr32?09/09 at32ap7002 picold.{d,w} ? load pico register(s) description reads the memory location specified into the given coprocessor register(s). operation: i. prhi:prlo *(rp + (ze(disp8) << 2)); ii. rp rp-8; prhi:prlo *(rp); iii. prhi:prlo *(rb + (ri << sa2)); iv. pr *(rp + (ze(disp8) << 2)); v. r p rp-4; pr *(rp); vi. pr *(rb + (ri << sa2)); syntax: i. picold.d prhi:prlo, rp[disp] ii. picold.d prhi:prlo, --rp iii. picold.d prhi:prlo, rb[ri< 62 32054f?avr32?09/09 at32ap7002 iii. iv. v. vi. example: picold.d coeff0_b:coeff0_a, r12[4] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 prlo[3:1] 0 0 1 shamt ri 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111010011010 rp 1514131211109876543210 pico cp# 0 pr disp8 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 0 pr 01 0 0 00 0 0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 pr 0 0 shamt ri
63 32054f?avr32?09/09 at32ap7002 picoldm ? load multiple pico registers description reads the memory locations specified into the given pico registers. the pointer register can optionally be updated after the operation. operation: i. ii. iii. loadaddress rp; if ( picoreglist contains config ) config *(loadaddress++); if ( picoreglist contains vmu2_out ) vmu2_out *(loadaddress++); if ( picoreglist contains vmu1_out ) vmu1_out *(loadaddress++); if ( picoreglist contains vmu0_out ) vmu0_out *(loadaddress++); if ( picoreglist contains coeff2_b) coeff2_b *(loadaddress++); if ( picoreglist contains coeff2_a) coeff2_a *(loadaddress++); if ( picoreglist contains coeff1_b) coeff1_b *(loadaddress++); if ( picoreglist contains coeff1_a) coeff1_a *(loadaddress++); if ( picoreglist contains coeff0_b) coeff0_b *(loadaddress++); if ( picoreglist contains coeff0_a) coeff0_a *(loadaddress++); if ( picoreglist contains outpix0) loadaddress++; if ( picoreglist contains outpix1) loadaddress++; if ( picoreglist contains outpix2) loadaddress++; if ( picoreglist contains inpix0) inpix0 *(loadaddress++); if ( picoreglist contains inpix1) inpix1 *(loadaddress++); if ( picoreglist contains inpix2) inpix2 *(loadaddress++); if opcode[++] == 1 then rp loadaddress; syntax: i. picoldm rp{++}, picoreglist ii. picoldm rp{++} , picoreglist iii. picoldm rp{++} , picoreglist operands: i. picoreglist { {inpix1, inpix2}, {outpix2, inpix0}, {outpix0, outpix1}, {coeff0_b, coeff0_a}, {coeff1_b, coeff1_a}, {coeff2_b, coeff2_a}, {vmu1_out, vmu0_out},
64 32054f?avr32?09/09 at32ap7002 {config, vmu2_out} } ii. picoreglist { inpix0, inpix1, inpix2, outpix0, outpix1, outpix2, coeff0_a, coeff0_b } iii. picoreglist { coeff1_a, coeff1_b, coeff2_a,coeff2_b, vmu0_out,vmu1_out, vmu2_out, config, } i-iii. p {0, 1, ?, 15} opcode i. ii. iii. example: i. picoldm r7++, coeff0_a, coeff0_b, co eff1_a, coeff1_b, coeff2_a, coeff2_b ii. picoldm r0, inpix0, inpix1, inpix2 iii. picoldm r12, vmu0_out, vmu1_out, vmu2_out 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 1 0 0 config vmu2_out vmu1_out vmu0_out coeff2_b coeff2_a coeff1_b coeff1_a coeff0_b coeff0_a outpix0 outpix1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 0 0 coeff0_b coeff0_a outpix0 outpi x1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 0 1 config vmu2_out vmu1_out vmu0_out co eff2_b coeff2_a co eff1_b coeff1_a
65 32054f?avr32?09/09 at32ap7002 picomv.{d,w} ? move between pico register(s) and register file description move the specified pico register(s) to register(s) in the register file or move register(s) in the register file to pico regis- ter(s). operation: i. prhi:prlo (rs+1:rs); ii. pr rs; iii. (rd+1:rd) prhi:prlo; iv. rd pr; syntax: i. picomv.d prhi:prlo, rs ii. picomv.w pr, rs iii. picomv.d rd, prhi:prlo iv. picomv.w rd, pr operands: i, ii. prhi:prlo { inpix1:inpix2, outpix2:inpix0, outpix0:outpix1, coeff0_b:coeff0_a, coeff1_b:coeff1_a, coeff2_b:coeff2_a, vmu1_out:vmu0_out, config:vmu2_out } ii, iv. pr { inpix0, inpix1, inpix2, outpix0, outpix1, outpix2, coeff0_a, coeff0_b, coeff1_a, coeff1_b, coeff2_a, coeff2_b, vmu0 _out, vmu1_out, vmu2_out, config} i. s {0, 2, 4, ?, 14} iii. d {0, 2, 4, ?, 14} ii. s {0, 1, ?, 15} iv. d {0, 1, ?, 15} opcode i. ii. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rs 0 1514131211109876543210 pico cp# 0 prlo[3:1] 000110000 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rs 1514131211109876543210 pico cp# 0 pr 00100000
66 32054f?avr32?09/09 at32ap7002 iii. iv. example: picomv.d r2, outpix0:outpix1 picomv.w config, lr 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rd 0 1514131211109876543210 pico cp# 0 prlo[3:1] 000010000 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rd 1514131211109876543210 pico cp# 0 pr 00000000
67 32054f?avr32?09/09 at32ap7002 picost.{d,w} ? store pico register(s) description stores the pico register value(s) to the memory location specified by the addressing mode. operation: i. *(rp + (ze(disp8) << 2)) prhi:prlo; ii. *(rp) prhi:prlo; rp rp+8; iii. *(rb + (ri << sa2)) prhi:prlo; iv. *(rp + (ze(disp8) << 2)) pr; v. * ( r p ) pr; rp rp-4; vi. *(rb + (ri << sa2)) pr; syntax: i. picost.d rp[disp], prhi:prlo ii. picost.d rp++, prhi:prlo iii. picost.d rb[ri< 68 32054f?avr32?09/09 at32ap7002 iii. iv. v. vi. example: picost.w r10++, outpix0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 prlo[3:1] 0 1 1 shamt ri 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111010111010 rp 1514131211109876543210 pico cp# 0 pr disp8 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 0 pr 01 1 0 00 0 0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 pr 1 0 shamt ri
69 32054f?avr32?09/09 at32ap7002 picostm ? store multip le pico registers description writes the pico registers specified in the regi ster list into the spec ified memory locations. operation: i. ii. iii. if opcode[--] == 1 then rp rp - 4*registersinlist; storeaddress rp; if ( picoreglist contains config ) *(storeaddress++) config; if ( picoreglist contains vmu2_out ) *(storeaddress++) vmu2_out; if ( picoreglist contains vmu1_out ) *(storeaddress++) vmu1_out; if ( picoreglist contains vmu0_out ) *(storeaddress++) vmu0_out; if ( picoreglist contains coeff2_b) *(storeaddress++) coeff2_b; if ( picoreglist contains coeff2_a) *(storeaddress++) coeff2_a; if ( picoreglist contains coeff1_b) *(storeaddress++) coeff1_b; if ( picoreglist contains coeff1_a) *(storeaddress++) coeff1_a; if ( picoreglist contains coeff0_b) *(storeaddress++) coeff0_b; if ( picoreglist contains coeff0_a) *(storeaddress++) coeff0_a; if ( picoreglist contains outpix0) *(storeaddress++) outpix0; if ( picoreglist contains outpix1) *(storeaddress++) outpix1; if ( picoreglist contains outpix2) *(storeaddress++) outpix2; if ( picoreglist contains inpix0) *(storeaddress++) inpix0 ; if ( picoreglist contains inpix1) *(storeaddress++) inpix1 ; if ( picoreglist contains inpix2) *(storeaddress++) inpix2 ; syntax: i. picostm {--}rp, picoreglist ii. picostm {--}rp, picoreglist iii. picostm {--}rp, picoreglist operands: i. picoreglist { {inpix1, inpix2}, {outpix2, inpix0}, {outpix0, outpix1}, {coeff0_b, coeff0_a}, {coeff1_b, coeff1_a}, {coeff2_b, coeff2_a}, {vmu1_out, vmu0_out},
70 32054f?avr32?09/09 at32ap7002 {config, vmu2_out} } ii. picoreglist { inpix0, inpix1, inpix2, outpix0, outpix1, outpix2, coeff0_a, coeff0_b } iii. picoreglist { coeff1_a, coeff1_b, coeff2_a,coeff2_b, vmu0_out,vmu1_out, vmu2_out, config, } i-iii. p {0, 1, ?, 15} opcode i. ii. iii. example: i. picostm --r7, coeff0_a, coeff0_b, coeff1_a, coeff1_b, coeff2_a, coeff2_b ii. picostm r2, outpix0, outpix1, outpix2 iii. picostm r11, vmu0_out, vmu1_out, vmu2_out 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 1 0 1 config vmu2_out vmu1_out vmu0_out coeff2_b coeff2_a coeff1_b coeff1_a coeff0_b coeff0_a outpix0 outpix1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 1 0 coeff0_b coeff0_a outpix0 outpi x1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 1 1 config vmu2_out vmu1_out vmu0_out co eff2_b coeff2_a co eff1_b coeff1_a
71 32054f?avr32?09/09 at32ap7002 7.9 data hazards data hazards are caused by data dependencies between instructions which are in different stages of the pipeline and reads/writes registers which are common to several pipeline stages. because of the 3-stage pipeline employed in the pico data hazards might exist between instructions. data hazards are handled by hardw are interlocks which can stall a new read com- mand from or write command to the pico register file. table 7-5. data hazards instruction next instruction condition stall cycles picovmul picovmac picosvmul picosvmac picomv.x pr,... picold.x picoldm write-after-read (war) or write-after-write (waw) hazard will occur if writing coeff n _a/b, vmu n _out or config since these ar e accessed when the pico command is in pipeline stage 2 and pipeline stage 3. 1 writes to inpix n registers produces no hazard since they are only accessed in pipeline stage 1. 0 picomv.x rd,... picost.x picostm read-after-write hazard (r aw) will occur if reading the pico register file while a command is in the pipeline. 2
72 32054f?avr32?09/09 at32ap7002 8. memories 8.1 embedded memories ? 32 kbyte sram ? implemented as two 16kbyte blocks ? single cycle access at full bus speed 8.2 physical memory map the system bus is implemented as an hsb bus matrix. all system bus addresses are fixed, and they are never remapped in any way, not even in boot. note that at32ap7002 by default uses segment translation, as described in the avr 32 architecture manual. the 32 bit physical address space is mapped as follows: accesses to unused areas returns an error result to the master requesting such an access. the bus matrix has the several masters and slaves. each master has its own bus and its own decoder, thus allowing a different memory mapping per master. the master number in the table below can be used to index the hmatrix contro l registers. for example, mcfg2 is associated with the hsb-hsb bridge. table 8-1. at32ap7002 physical memory map start address size device 0x0000_0000 64 mbyte ebi sram cs0 0x0400_0000 64 mbyte ebi sram cs4 0x0800_0000 64 mbyte ebi sram cs2 0x0c00_0000 64 mbyte ebi sram cs3 0x1000_0000 256 mbyte ebi sram/sdram cs1 0x2000_0000 64 mbyte ebi sram cs5 0x2400_0000 16 kbyte internal sram 0 0x2400_4000 16 kbyte internal sram1 0xff00_0000 4 kbyte lcdc configuration 0xff20_0000 1 kbyte dmaca configuration 0xff30_0000 1 mbyte usba data 0xffe0_0000 1 mbyte pba 0xfff0_0000 1 mbyte pbb
73 32054f?avr32?09/09 at32ap7002 each slave has its own arbiter, thus allowing a different arbitration per slave. the slave number in the table below can be used to index the hmatrix control registers. for example, scfg3 is associated with pbb. table 8-2. hsb masters master 0 cpu dcache master 1 cpu icache master 2 hsb-hsb bridge master 3 isi dma master 4 usba dma master 5 lcd controller dma master 8 dmac master interface 0 master 9 dmac master interface 1 table 8-3. hsb slaves slave 0 internal sram 0 slave 1 internal sram1 slave 2 pba slave 3 pbb slave 4 ebi slave 5 usba data slave 6 lcdc configuration slave 7 dmaca configuration
74 32054f?avr32?09/09 at32ap7002 9. peripherals 9.1 peripheral address map table 9-1. peripheral address mapping address peripheral name bus 0xff000000 lcdc lcd controller slave interface - lcdc hsb 0xff200000 dmaca dma controller slave interface- dmaca hsb 0xff300000 usba usb slave interface - usba hsb 0xffe00000 spi0 serial peripheral interface - spi0 pb a 0xffe00400 spi1 serial peripheral interface - spi1 pb a 0xffe00800 twi two-wire interface - twi pb a 0xffe00c00 usart0 universal synchronous asynchronous receiver transmitter - usart0 pb a 0xffe01000 usart1 universal synchronous asynchronous receiver transmitter - usart1 pb a 0xffe01400 usart2 universal synchronous asynchronous receiver transmitter - usart2 pb a 0xffe01800 usart3 universal synchronous asynchronous receiver transmitter - usart3 pb a 0xffe01c00 ssc0 synchronous serial controller - ssc0 pb a 0xffe02000 ssc1 synchronous serial controller - ssc1 pb a 0xffe02400 ssc2 synchronous serial controller - ssc2 pb a 0xffe02800 pioa parallel input/output 2 - pioa pb a 0xffe02c00 piob parallel input/output 2 - piob pb a 0xffe03000 pioc parallel input/output 2 - pioc pb a 0xffe03400 piod parallel input/output 2 - piod pb a
75 32054f?avr32?09/09 at32ap7002 0xffe03800 pioe parallel input/output 2 - pioe pb a 0xffe03c00 psif ps2 interface - psif pb a 0xfff00000 pm power manager - pm pb b 0xfff00080 rtc real time counter- rtc pb b 0xfff000b0 wdt watchdog timer- wdt pb b 0xfff00100 eic external interrupt controller - eic pb b 0xfff00400 intc interrupt controller - intc pb b 0xfff00800 hmatrix hsb matrix - hmatrix pb b 0xfff00c00 tc0 timer/counter - tc0 pb b 0xfff01000 tc1 timer/counter - tc1 pb b 0xfff01400 pwm pulse width modulation controller - pwm pb b 0xfff02000 abdac audio bitstream dac - abdac pb b 0xfff02400 mci multimedia card interface - mci pb b 0xfff02800 ac97c ac97 controller - ac97c pb b 0xfff02c00 isi image sensor interface - isi pb b 0xfff03000 usba usb configuration interface - usba pb b 0xfff03400 smc static memory controller - smc pb b 0xfff03800 sdramc sdram controller - sdramc pb b 0xfff03c00 ecc error correcting code controller - ecc pb b table 9-1. peripheral address mapping (continued) address peripheral name bus
76 32054f?avr32?09/09 at32ap7002 9.2 interrupt r equest signal map the various modules may output interrupt request signals. these signals are routed to the inter- rupt controller (intc). the interrupt controller supports up to 64 groups of interrupt requests. each group can have up to 32 interrupt request signals. all interrupt signals in the same group share the same autovector address and priority level. refer to the documentation for the individ- ual submodules for a description of the semantic of the different interrupt requests. the interrupt request signals in at32ap700 2 are connected to the intc as follows: table 9-2. interrupt request signal map group line signal 0 0 count-compare match 1 performance counter overflow 1 0 lcdc eof 1 lcdc ln 2 lcdc lstln 3 lcdc mer 4 lcdc owr 5 lcdc uflw 2 0 dmaca block 1 dmaca dstt 2dmaca err 3 dmaca srct 4dmaca tfr 3 0 spi 0 4 0 spi 1 50twi 6 0 usart0 7 0 usart1 8 0 usart2 9 0 usart3 10 0 ssc0 11 0 ssc1 12 0 ssc2 13 0 pioa 14 0 piob 15 0 pioc 16 0 piod 17 0 pioe 18 0 psif
77 32054f?avr32?09/09 at32ap7002 9.3 dmaca handshake interface map the following table details the hardware handshake map between the dmaca and the peripher- als attached to it: : 19 0 eic0 1eic1 2eic2 3eic3 20 0 pm 21 0 rtc 22 0 tc00 1tc01 2tc02 23 0 tc10 1tc11 2tc12 24 0 pwm 27 0 abdac 28 0 mci 29 0 ac97c 30 0 isi 31 0 usba 32 0 ebi table 9-2. interrupt request signal map group line signal table 9-3. hardware handshaking connection request hardware handshaking interface mci rx 0 mci tx 1 abdac tx 2 ac97c channel a rx 3 ac97c channel a tx 4 ac97c channel b rx 5 ac97c channel b tx 6 external dma request 0 7 external dma request 1 8 external dma request 2 9 external dma request 3 10
78 32054f?avr32?09/09 at32ap7002 9.4 clock connections 9.4.1 timer/counters each timer/counter channel can independently select an internal or external clock source for its counter: 9.4.2 usarts each usart can be connected to an internally divided clock: table 9-4. timer/counter clock connections timer/counter source name connection 0 internal timer_clock1 clk_osc32 timer_clock2 clk_pbb / 4 timer_clock3 clk_pbb / 8 timer_clock4 clk_pbb / 16 timer_clock5 clk_pbb / 32 external xc0 see section 9.7 xc1 xc2 1 internal timer_clock1 clk_osc32 timer_clock2 clk_pbb / 4 timer_clock3 clk_pbb / 8 timer_clock4 clk_pbb / 16 timer_clock5 clk_pbb / 32 external xc0 see section 9.7 xc1 xc2 table 9-5. usart clock connections usart source name connection 0 internal clk_div clk_pba / 8 1 2 3
79 32054f?avr32?09/09 at32ap7002 9.4.3 spis each spi can be connected to an internally divided clock: 9.4.4 usba osc1 is connected to the usb hs phy and must be 12 mhz when using the usba. 9.5 external inte rrupt pin mapping external interrupt requests are connected to the following pins:: 9.6 nexus ocd aux port connections if the ocd trace system is enabled, the trace system will take control over a number of pins, irre- spectively of the pio configuration. two different ocd trace pi n mappings are possible, depending on the configuration of the ocd axs register. for details, see the avr32 ap techni- cal reference manual. table 9-6. spi clock connections spi source name connection 0 internal clk_div clk_pba / 32 1 table 9-7. external interrupt pin mapping source connection nmi_n pb24 extint0 pb25 extint1 pb26 extint2 pb27 extint3 pb28 table 9-8. nexus ocd aux port connections pin axs=0 axs=1 evti_n evti_n evti_n mdo[5] pb09 pc18 mdo[4] pb08 pc14 mdo[3] pb07 pc12 mdo[2] pb06 pc11 mdo[1] pb05 pc06 mdo[0] pb04 pc05 evto_n pb03 pb28 mcko pb02 pc02 mseo[1] pb01 pc01 mseo[0] pb00 pc00
80 32054f?avr32?09/09 at32ap7002 9.7 peripheral multiplexing on io lines the at32ap7002 features five pio controllers, pioa to pioe, that multiplex the i/o lines of the peripheral set. each pio controller controls up to thirty-two lines. each line can be assigned to one of two peripheral functions, a or b. the tables in the following pages define how the i/o lines of the peripherals a and b are multiplexed on the pio controllers. note that some output only peripheral func tions might be duplicated within the tables. 9.7.1 pio controller a multiplexing table 9-9. pio controller a multiplexing ctbga196 i/o line peripheral a peripheral b j3 pa00 spi0 - miso ssc1 - rx_frame_sync j1 pa01 spi0 - mosi ssc1 - tx_frame_sync g6 pa02 spi0 - sck ssc1 - tx_clock j2 pa03 spi0 - npcs[0] ssc1 - rx_clock g5 pa04 spi0 - npcs[1] ssc1 - tx_data k1 pa05 spi0 - npcs[2] ssc1 - rx_data c9 pa06 twi - sda usart0 - rts e9 pa07 twi - scl usart0 - cts g7 pa08 psif - clock usart0 - rxd j6 pa09 psif - data usart0 - txd h6 pa10 mci - clk usart0 - clk k2 pa11 mci - cmd tc0 - clk0 k3 pa12 mci - data[0] tc0 - a0 m1 pa13 mci - data[1] tc0 - a1 h7 pa14 mci - data[2] tc0 - a2 n1 pa15 mci - data[3] tc0 - b0 k4 pa16 usart1 - clk tc0 - b1 p1 pa17 usart1 - rxd tc0 - b2 j7 pa18 usart1 - txd tc0 - clk2 l3 pa19 usart1 - rts tc0 - clk1 n2 pa20 usart1 - cts spi0 - npcs[3] l2 pa21 ssc0 - rx_frame_sync pwm - pwm[2] m2 pa22 ssc0 - rx_clock pwm - pwm[3] m3 pa23 ssc0 - tx_clock tc1 - a0 p2 pa24 ssc0 - tx_frame_sync tc1 - a1 l7 pa25 ssc0 - tx_data tc1 - b0 k7 pa26 ssc0 - rx_data tc1 - b1 p9 pa27 spi1 - npcs[3] tc1 - clk0 h9 pa28 pwm - pwm[0] tc1 - a2
81 32054f?avr32?09/09 at32ap7002 9.7.2 pio controller b multiplexing l8 pa29 pwm - pwm[1] tc1 - b2 m8 pa30 pm - gclk[0] tc1 - clk1 p10 pa31 pm - gclk[1] tc1 - clk2 table 9-9. pio controller a multiplexing table 9-10. pio controller b multiplexing ctbga196 i/o line peripheral a peripheral b e11 pb00 isi - data[0] spi1 - miso d14 pb01 isi - data[1] spi1 - mosi c14 pb02 isi - data[2] spi1 - npcs[0] b14 pb03 isi - data[3] spi1 - npcs[1] a14 pb04 isi - data[4] spi1 - npcs[2] a13 pb05 isi - data[5] spi1 - sck b13 pb06 isi - data[6] mci - cmd[1] c13 pb07 isi - data[7] mci - data[4] a12 pb08 isi - hsync mci - data[5] b12 pb09 isi - vsync mci - data[6] c12 pb10 isi - pclk mci - data[7] a11 pb11 psif - clock[1] isi - data[8] b11 pb12 psif - data[1] isi - data[9] d12 pb13 ssc2 - tx_data isi - data[10] c11 pb14 ssc2 - rx_data isi - data[11] d11 pb15 ssc2 - tx_clock usart3 - cts a10 pb16 ssc2 - tx_frame_sync usart3 - rts b10 pb17 ssc2 - rx_frame_sync usart3 - txd a9 pb18 ssc2 - rx_clock usart3 - rxd c10 pb19 pm - gclk[2] usart3 - clk d10 pb20 abdac - data[1] ac97c - sdo b9 pb21 abdac - data[0] ac97c - sync a8 pb22 abdac - datan[1] ac97c - sclk b8 pb23 abdac - datan[0] ac97c - sdi h5 pb24 nmi_n dmaca - dmarq[0] l1 pb25 extint0 dmaca - dmarq[1] n9 pb26 extint1 usart2 - rxd j9 pb27 extint2 usart2 - txd k9 pb28 extint3 usart2 - clk n12 pb29 pm - gclk[3] usart2 - cts o14 pb30 pm - gclk[4] usart2 - rts
82 32054f?avr32?09/09 at32ap7002
83 32054f?avr32?09/09 at32ap7002 9.7.3 pio controller c multiplexing 9.7.4 pio controller d multiplexing table 9-11. pio controller c multiplexing ctbga196 i/o line peripheral a peripheral b a7 pc20 lcdc - hsync c8 pc21 lcdc - pclk b7 pc22 lcdc - vsync a6 pc23 lcdc - dval a5 pc28 lcdc - data[2] c7 pc29 lcdc - data[3] d8 pc30 lcdc - data[4] e8 pc31 lcdc - data[5] table 9-12. pio controller d multiplexing ctbga196 i/o line peripheral a peripheral b d2 pd00 lcdc - data[6] c2 pd01 lcdc - data[7] f4 pd04 lcdc - data[10] g1 pd05 lcdc - data[11] g3 pd06 lcdc - data[12] e5 pd07 lcdc - data[13] g2 pd08 lcdc - data[14] f5 pd09 lcdc - data[15] n3 pd12 lcdc - data[18] p3 pd13 lcdc - data[19] p4 pd14 lcdc - data[20] n4 pd15 lcdc - data[21] n5 pd16 lcdc - data[22] m4 pd17 lcdc - data[23]
84 32054f?avr32?09/09 at32ap7002 9.7.5 io pins without multiplexing many of the external ebi pins are not controlled by the pio modules, but directly driven by the ebi. these pins have programmable pullup resistor s. these resistors are controlled by special function register 4 (sfr4) in the hmatrix. the pullup on the lines multiplexed with pio is controlled by the appropriate pio control register. this sfr can also control compactflash, smartmedia or nandflash support, see the ebi chap- ter for details 9.7.5.1 hmatrix sfr4 ebi control register name: hmatrix_sfr4 access type: read/write ? cs1a: chip select 1 assignment 0 = chip select 1 is assigned to the static memory controller. 1 = chip select 1 is assign ed to the sdram controller. ? cs3a: chip select 3 assignment 0 = chip select 3 is only assigned to the static memory contro ller and ncs3 behaves as defined by the smc. 1 = chip select 3 is assigned to the static memory controller and the nand flash/smartmedia logic is activated. ? cs4a: chip select 4 assignment 0 = chip select 4 is assigned to the stat ic memory controller and ncs4, ncs5 and ncs6 behave as defined by the smc. 1 = chip select 4 is assigned to the static memory controller and the compactflash logic is activated. ? cs5a: chip select 5 assignment 0 = chip select 5 is assigned to the stat ic memory controller and ncs4, ncs5 and ncs6 behave as defined by the smc. 1 = chip select 5 is assigned to the static memory controller and the compactflash logic is activated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????ebi_dbpuc 76543210 ? ? ebi_cs5a ebi_cs4a ebi_cs3a ? ebi_cs1a -
85 32054f?avr32?09/09 at32ap7002 accessing the address space reserved to ncs5 and ncs6 may lead to an unpredictable outcome. ? ebi_dbpuc: ebi data bus pull-up control 0: ebi d[15:0] are internally pulled up to the vddio power supply. the pull-up resistors are enabled after reset. 1: ebi d[15:0] are not internally pulled up. table 9-13. io pins without multiplexing i/o line function px00 ebi - data[0] px01 ebi - data[1] px02 ebi - data[2] px03 ebi - data[3] px04 ebi - data[4] px05 ebi - data[5] px06 ebi - data[6] px07 ebi - data[7] px08 ebi - data[8] px09 ebi - data[9] px10 ebi - data[10] px11 ebi - data[11] px12 ebi - data[12] px13 ebi - data[13] px14 ebi - data[14] px15 ebi - data[15] px16 ebi - addr[0] px17 ebi - addr[1] px18 ebi - addr[2] px19 ebi - addr[3] px20 ebi - addr[4] px21 ebi - addr[5] px22 ebi - addr[6] px23 ebi - addr[7] px24 ebi - addr[8] px25 ebi - addr[9] px26 ebi - addr[10] px27 ebi - addr[11] px28 ebi - addr[12] px29 ebi - addr[13] px30 ebi - addr[14] px31 ebi - addr[15]
86 32054f?avr32?09/09 at32ap7002 px32 ebi - addr[16] px33 ebi - addr[17] px34 ebi - addr[18] px35 ebi - addr[19] px36 ebi - addr[20] px37 ebi - addr[21] px38 ebi - addr[22] px39 ebi - ncs[0] px40 ebi - ncs[1] px41 ebi - ncs[3] px42 ebi - nrd px43 ebi - nwe0 px44 ebi - nwe1 px45 ebi - nwe3 px46 ebi - sdck px47 ebi - sdcke px48 ebi - ras px49 ebi - cas px50 ebi - sdwe px51 ebi - sda10 px52 ebi - nandoe px53 ebi - nandwe table 9-13. io pins without multiplexing (continued)
87 32054f?avr32?09/09 at32ap7002 9.8 peripheral overview 9.8.1 external bus interface ? optimized for application memory space support ? integrates three external memory controllers: ? static memory controller ? sdram controller ? ecc controller ? additional logic for nand flash/smartmedia tm and compactflash tm support ? smartmedia support: 8-bit as well as 16-bit devices are supported ? compactflash support: all modes (attribute memory, common memory, i/o, true ide) are supported but the signal s _iois16 (i/o and true ide modes) and _ata sel (true ide mode) are not handled. ? optimized external bus: ? 16- or 32-bit data bus ? up to 26-bit address bus, up to 64-mbytes addressable ? optimized pin multiplexing to redu ce latencies on external memories ? up to 6 chip selects, configurable assignment: ? static memory controller on ncs0 ? sdram controller or static memory controller on ncs1 ? static memory controller on ncs2 ? static memory controller on ncs 3, optional nand flash/smartmedia tm support ? static memory controller on ncs 4 - ncs5, optional compactflash tm support 9.8.2 static memory controller ? 6 chip selects available ? 64-mbyte address space per chip select ? 8-, 16- or 32-bit data bus ? word, halfword, byte transfers ? byte write or by te select lines ? programmable setup, pulse and hold ti me for read signals per chip select ? programmable setup, pulse and hold time for write signals per chip select ? programmable data float time per chip select ? compliant with lcd module ? external wait request ? automatic switch to slow clock mode ? asynchronous read in page mode supporte d: page size ranges from 4 to 32 bytes 9.8.3 sdram controller ? numerous configurations supported ? 2k, 4k, 8k row address memory parts ? sdram with two or four internal banks ? sdram with 16- or 32-bit data path ? programming facilities ? word, half-word, byte access ? automatic page break when memory boundary has been reached ? multibank ping-pong access ? timing parameters specified by software ? automatic refresh operation, refresh rate is programmable
88 32054f?avr32?09/09 at32ap7002 ? energy-saving capabilities ? self-refresh, power-down and deep power modes supported ? supports mobile sdram devices ? error detection ? refresh error interrupt ? sdram power-up initialization by software ? cas latency of 1, 2, 3 supported ? auto precharge command not used 9.8.4 error corrected code controller ? hardware error corrected code (ecc) generation ? detection and correction by software ? supports nand flash and smartmedia ? devices with 8- or 16-bit data path. ? supports nand flash/smartmedia with page size s of 528, 1056, 2112 and 4224 bytes, specified by software 9.8.5 serial peripheral interface ? supports communication with serial external devices ? four chip selects with extern al decoder support allow co mmunication with up to 15 peripherals ? serial memories, such as da taflash? and 3-wire eeproms ? serial peripherals, such as adcs, dacs, l cd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 8- to 16-bit programmable da ta length per chip select ? programmable phase and polarity per chip select ? programmable transfer delays between consecutive transfers and between clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? very fast transfers supported ? transfers with baud rates up to mck ? the chip select line may be left active to speed up transfer s on the same device 9.8.6 two-wire interface ? compatibility with standard two-wire serial memory ? one, two or three bytes for slave address ? sequential read/write operations
89 32054f?avr32?09/09 at32ap7002 9.8.7 usart ? programmable baud rate generator ? 5- to 9-bit full-duplex synchronous or asynchronous serial communications ? 1, 1.5 or 2 stop bits in a synchronous mode or 1 or 2 stop bits in synchronous mode ? parity generation and error detection ? framing error detection, overrun error detection ? msb- or lsb-first ? optional break generation and detection ? by 8 or by-16 over-sampling receiver frequency ? hardware handshaking rts-cts ? receiver time-out and transmitter timeguard ? optional multi-drop mode with address generation and detection ? optional manchester encoding ? rs485 with driver control signal ? iso7816, t = 0 or t = 1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit ? irda modulation and demodulation ? communication at up to 115.2 kbps ? test modes 46 ? remote loopback, local loopback, automatic echo 9.8.8 serial synchronous controller ? provides serial synchronous communication links used in audio and tel ecom applications (with codecs in master or slave modes, i2s, tdm buses, magnetic card reader, etc.) ? contains an independent receiver and transmitter and a common clock divider ? offers a configurable frame sync and data length ? receiver and transmitter can be programmed to st art automatically or on detection of different event on the frame sync signal ? receiver and transmitter include a data signal, a cloc k signal and a frame synchronization signal 9.8.9 ac97 controller ? compatible with ac97 comp onent specification v2.2 ? capable to interface with a single analog front end ? three independent rx channels and three independent tx channels ? one rx and one tx channel dedicated to the ac97 analog front end control ? one rx and one tx channel for data transfers, connected to the dmaca ? one rx and one tx channel for data transfers, connected to the dmaca ? time slot assigner allowing to assign up to 12 time slots to a channel ? channels support mono or stereo up to 20 bit sample length - variable sampling rate ac97 codec interface (48khz and below)
90 32054f?avr32?09/09 at32ap7002 9.8.10 audio bitstream dac ? digital stereo dac ? oversampled d/a conversion architecture ? oversampling ratio fixed 128x ? fir equalization filter ? digital interpolation filter: comb4 ? 3rd order sigma-delta d/a converters ? digital bitstream outputs ? parallel interface ? connected to dma controller for backgrou nd transfer without cpu intervention 9.8.11 timer counter ? three 16-bit timer counter channels ? wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ? delay timing ? pulse width modulation ? up/down capabilities ? each channel is user-conf igurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? two global registers that ac t on all three tc channels 9.8.12 pulse width modulation controller ? 4 channels, one 16-bit counter per channel ? common clock generator, providing thirteen different clocks ? a modulo n counter providing eleven clocks ? two independent linear dividers working on modulo n counter outputs ? independent channel programming ? independent enable disable commands ? independent clock ? independent period and duty cycle, with double bufferization ? programmable selection of the output waveform polarity ? programmable center or left aligned output waveform
91 32054f?avr32?09/09 at32ap7002 9.8.13 multimedia card interface ? 2 double-channel multimedia card interface, al lowing concurrent transfers with 2 cards ? compatibility with multimedia card specification version 2.2 ? compatibility with sd memory card specification version 1.0 ? compatibility with sdio specification version v1.0. ? cards clock rate up to master clock divided by 2 ? embedded power management to slow down clock rate when not used ? each mci has two slot, each supporting ? one slot for one multimediacard bus (up to 30 cards) or ?one sd memory card ? support for stream, block and multi-block data read and write 9.8.14 ps/2 interface ? peripheral bus slave ? ps/2 host ? receive and transmit capability ? parity generation and error detection ? overrun error detection 9.8.15 usb interface ? supports hi (480mbps) and full (12mbps) speed communication ? compatible with the usb 2.0 specification ? utmi compliant ? 7 endpoints ? embedded dual-port ram for endpoints ? suspend/resume logic (command of utmi) ? up to three memory banks for endpoints (not for control endpoint) ? 4 kbytes of dpram 9.8.16 lcd controller ? single and dual scan color and monoch rome passive stn lcd panels supported ? single scan active tft lcd panels supported ? 4-bit single scan, 8-bit single or dual scan, 16-bit dual scan stn interfaces supported ? up to 24-bit single scan tft interfaces supported ? up to 16 gray levels for mono stn and up to 4096 colors for color stn displays ? 1, 2 bits per pixel (palletized), 4 bits per pixel (non-palletized) for mono stn ? 1, 2, 4, 8 bits per pixel (palletized), 16 bits per pixel (non-palletized) for color stn ? 1, 2, 4, 8 bits per pixel (palletized), 16 , 24 bits per pixel (non-palletized) for tft ? single clock domain architecture ? resolution supported up to 2048x2048 ? 2d-dma controller for manageme nt of virtual frame buffer ? allows management of frame buffer larger than the screen size and moving the view over this virtual frame buffer ? automatic resynchronization of the fram e buffer pointer to prevent flickering ? configurable coefficien ts with flexible fixe d-point representation.
92 32054f?avr32?09/09 at32ap7002 ? 9.8.17 image sensor interface ? itu-r bt. 601/656 8-bit mode external interface support ? support for itu-r bt.656-4 sav and eav synchronization ? vertical and horizontal re solutions up to 2048 x 2048 ? preview path up to 640*480 ? support for packed data formatting for ycbcr 4:2:2 formats ? preview scaler to generate smaller size image 50 ? programmable frame capture rate
93 32054f?avr32?09/09 at32ap7002 10. power manager (pm) rev: 1.0.2.8 10.1 features ? controls oscillators and plls ? generates clocks and resets for digital logic ? supports 2 high-speed crystal oscillators ? supports 2 plls ? supports 32khz ultra-low power oscillator ? on-the fly frequency change of cpu, hsb, and pb frequency ? sleep modes allow simple disabling of logic clocks, pll?s and oscillators ? module-level clock gating through maskable peripheral clocks ? wake-up from interrupts or external pin ? generic clocks with wide frequency range provided ? automatic identificat ion of reset sources 10.2 description the power manager (pm) controls the oscillators, pll?s, and generates the clocks and resets in the device. the pm controls two fast crystal oscillators, as well as two pll?s, which can multiply the clock from either oscillato r to provide higher frequencies. additionally, a low-power 32khz oscillator is used to generate a slow clock for real-time counters. the provided clocks are divided into synchr onous and generic clocks. the synchronous clocks are used to clock the main digital logic in the device, namely the cpu, and the modules and peripherals connected to the hsb, pba, and pbb buses. the generic clocks are asynchronous clocks, which can be tuned precisely within a wide frequency range, which makes them suitable for peripherals that require specific frequencies, such as timers and communication modules. the pm also contains advanced power-saving feat ures, allowing the user to optimize the power consumption for an application. the synchronous cl ocks are divided into four clock domains, for the cpu, and modules on the h sb, pba, and pbb buses. the fo ur clocks can run at different speeds, so the user can save power by running pe ripherals at a relatively low clock, while main- taining a high cpu performance. additionally, the clocks can be independently changed on-the fly, without halting any peripherals. this enables the user to adjust the speed of the cpu and memories to the dynamic load of the applicati on, without disturbing or re-configuring active peripherals. each module also has a separate clock, enabling t he user to switch off the clock for inactive modules, to save further pow er. additionally, clocks and os cillators can be automatically swithced off during idle period s by using the sleep instruction on the cpu. the system will return to normal on occurence of interrup ts or an event on the wake_n pin. the power manager also cointains a reset contro ller, which collects all possible reset sources, generates hard and soft resets, and allows the reset source to be identifed by software.
94 32054f?avr32?09/09 at32ap7002 10.3 block diagram sleep controller oscillator and pll control pll0 pll1 synchronous clock generator generic clock generator reset controller oscillator 0 oscillator 1 32 khz oscillator startup counter slow clock sleep instruction oscen_n wake_n reset_n power-on detector soft reset sources resets generic clocks synchronous clocks osc/pll control signals
95 32054f?avr32?09/09 at32ap7002 10.4 product dependencies 10.4.1 i/o lines the pm provides a number of generic clock out puts, which can be connected to output pins, multiplexed with pio lines. the programmer must first program the pio controller to assign these pins to their peripheral function. if the i/o pins of the pm are not used by the application, they can be used for other purposes by the pio controller. the pm also has a dedicated w ake_n pin, as well as a number of pins for oscillators and pll?s, which do not require the pio controller to be programmed. 10.4.2 interrupt the pm interrupt line is connected to one of the internal sources of the interrupt controller. using the pm interrupt requires the interrupt controller to be programmed first. 10.5 functional description 10.5.1 oscillator 0 and 1 operation the two main oscillators are designed to be us ed with an external high frequency crystal, as shown in figure 10-1 . see electrical characteristics for the allowed frequency range. the main oscillators are enabled by defaul t after reset, and are only s witched off in sleep modes, as described in section 10.5.6 on page 101 . after a power-on reset, or when waking up from a sleep mode that disabled the main oscillators, the oscilla tors need 128 slow clock cycles to sta- bilize on the correct frequency. (1) the pm masks the main oscillato r outputs during this start-up period, to ensure that no unstable clocks propagate to the digital logic. the oscillators can be bypassed by pulling the os cen_n pin high. this disables the oscillators, and an external clock must be applied on xin. no start-up time applies to this clock. figure 10-1. oscillator connections 10.5.2 32 khz oscillator operation the 32 khz oscillator operates similarly to oscillator 0 and 1 described above, and is used to generate the slow clock in the device. a 32768 hz crystal must be connected between xin32 and xout32 as shown in figure 10-1 . the 32 khz oscillator is is an ultra-low power design, and remains enabled in all sleep modes except static mode, as described in section 10.5.6 on page 1. when waking up from stop mode using external interrupts, the startup time is 32768 slow clock cycles. xin xout c 2 c 1 typ. values: c 2 = c 2 = 22 pf
96 32054f?avr32?09/09 at32ap7002 101 . the oscillator has a rather lo ng start-up time of 32768 cl ock cycles, and no clocks will be generated in the device during this start-up time. note that in static sl eep mode the star tup counter will start at the neg edge of reset and not at the posedge. pulling oscen_n high will also disable the 32 khz oscillator, and a 32 khz clock must be applied on the xin32 pin. no start-up time applies to this clock. 10.5.3 pll operation the device contains two pll?s, pll0 and pll1. these are disabled by default, but can be enabled to provide high frequency source clocks for synchronous or generic clocks. the pll?s can take either oscillator 0 or 1 as clock source. each pll has an input divider, which divides the source clock, creating the reference clock for the pll. the pll output is divided by a user- defined factor, and the pll compares the resulting clock to the reference cl ock. the pll will adjust its output frequency until the two compar ed clocks are equal, thus locking the output fre- quency to a multiple of the reference clock frequency. when the pll is switched on, or when changing the clock source or multiplication or division factor for the pll, the pll is unlocked and the output frequency is undefined. the pll clock for the digital logic is automatically masked when th e pll is unlocked, to prevent connected digital logic from receiving a too high frequency and thus become unstable.
97 32054f?avr32?09/09 at32ap7002 figure 10-2. pll with control logic and filters 10.5.3.1 enabling the pll plln is enabled by writing the pllen bit in th e plln register. pllosc selects oscillator 0 or 1 as clock source. the plldiv and pllmul bitfields must be written with the division and multipli- cation factor, respectively, creating the pll frequency: f pll = (pllmul+1) / (plldiv+1) ? f osc the lockn flag in isr is set when plln become s locked. the bit will stay high until cleared by writing 1 to icr:lockn. the po wer manager interrupt can be tr iggered by writing ier:lockn to 1. note that the input frequency for the pll must be within the range inidicated in the electrical characteristics chapter. the input frequency for the pll relates to the oscillator frequency and plldiv setting as follows: f pllin = 2 ? f osc / (plldiv+1)? pll output divider input divider lft 0 1 osc0 clock osc1 clock pllosc pllen pllopt pllmul plldiv lock suppression pllcount lock mask pll clock c 1 r 1 c 2
98 32054f?avr32?09/09 at32ap7002 10.5.3.2 lock suppression when using high division or multiplication factors, there is a possibility that the pll can give false lock indications while sweeping to the corr ect frequency. to prevent false lock indications from setting the lockn flag, the lock indication can be suppressed for a number of slow clock cycles indicated in the plln:count field. typi cal start-up times can be found using the atmel filter caluclator (see below). 10.5.3.3 operating range selection to use plln, a passive rc filter should be connected to the lftn pin, as shown in figure 10-2 . filter values depend on the pll reference and output frequency range. atmel provides a tool named ?atmel pll lft filter calculator at91?. the pll for at32ap7002 can be selected in this tool by selecting ?at91rm9200 (58a07f)? and leave ?icp = ?1?? (default). 10.5.4 synchronous clocks oscillator 0 (default) or pll0 prov ides the source for the main cl ocks, which is the common root for the synchronous clocks for the cpu, and hsb, pba, and pbb modules. the main clock is divided by an 8-bit prescaler, and each of these four synchronous clocks can run from any tap- ping of this prescaler, or the undivided main clock, as long as f cpu f hsb f pbx and f pbb =f hsb . the synchronous clock source can be changed on- the fly, responding to varying load in the application. the clock domains can be shut down in sleep mode, as described in ?sleep modes? on page 101 . additionally, the clocks for each module in the four domains can be individually masked, to avoid power consumption in inactive modules. figure 10-3. synchronous clock generation mask prescaler 0 1 osc0 clock pll0 clock pllsel 0 1 cpusel cpudiv main clock sleep controller cpumask cpu clocks hsb clocks pbaclocks pbb clocks sleep instruction
99 32054f?avr32?09/09 at32ap7002 10.5.4.1 selecting pll or os cillator for the main clock the common main clock can be c onnected to oscillator 0 or pll0 . by default, the main clock will be connected to the osc illator 0 output. the user can connec t the main clock to the pll0 output by writing the pllsel bit in the main clock cont rol register (mcctrl) to 1. this must only be done after pll0 has been enabled, otherwise a deadlock will occur. care should also be taken that the new frequency of the synchronous clocks does not exceed the maximum frequency for each clock domain. 10.5.4.2 selecting synchronous clock division ratio the main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks. by default, the synchronous clocks run on the undivided main clock. the user can select a pres- caler division for the cpu clock by writing c ksel:cpudiv to 1 and cpusel to the prescaling value, resulting in a cpu clock frequency: f cpu = f main / 2 (cpusel+1) similarly, the clock for hsb, pba, and pbb can be divided by writing their respective bitfields. to ensure correct operation, frequencies must be selected so that f cpu f hsb f pba,b . also, fre- quencies must never exceed the specified maximum frequency for each clock domain. cksel can be written without hal ting or disabling peripheral m odules. writing cksel allows a new clock setting to be written to all synchronous clocks at the sa me time. it is possible to keep one or more clocks unchanged by writing the same value a before to the xxxdiv and xxxsel bit- fields. this way, it is possible to e.g. scale cpu and hsb speed according to the required performance, while keeping the pba and pbb frequency constant. 10.5.4.3 clock ready flag there is a slight delay from cksel is written and the new clock setting becomes effective. dur- ing this interval, the clock ready (c krdy) flag in isr will read as 0. if ier:ckrdy is written to 1, the power manager interrupt can be triggered when the new clock setting is effective. cksel must not be re-written while ckrdy is 0, or the system may become unstable or hang. 10.5.5 peripheral clock masking by default, the clock for all modules are enabled, regardless of which modules are actually being used. it is possible to disable the clock for a module in the cpu, hsb, pba, or pbb clock domain by writing the corresponding bit in the clock mask register (cpu/hsb/pba/pbb) to 0. when a module is not clocked, it will cease operation, and its re gisters cannot be read or written. the module can be re-enabled later by writing the corresponding mask bit to 1. a module may be connected to several clock domains, in which case it will have several mask bits. table 10-1 contains a list of impl emented maskable clocks. 10.5.5.1 cautionary note note that clocks should only be switched off if it is certain that the module will not be used. switching off the clock for the internal ram will cause a pr oblem if the stack is mapped there. switching off the clock to the power manager (pm), which contains the mask registers, or the corresponding pb bridge, will make it impossible to write the mask registers again. in this case, they can only be re-enabled by a system reset.
100 32054f?avr32?09/09 at32ap7002 10.5.5.2 mask ready flag due to synchronization in the clock generator, there is a slight delay from a mask register is writ- ten until the new mask setting goes into effect. when clearing mask bits, this delay can usually be ignored. however, when setting mask bits, the registers in the corresponding module must not be written until the clock has actually be re-enabled. the status flag mskrdy in isr pro- vides the required mask status information. when wr iting either mask register with any value, this bit is cleared. the bit is set when the clocks have been enabled and disabled according to the new mask setting. optionally, the power ma nager interrupt can be enabled by writing the mskrdy bit in ier.
101 32054f?avr32?09/09 at32ap7002 10.5.6 sleep modes in normal operation, all clock domains are active, allowing software execution and peripheral operation. when the cpu is idle, it is possible to switch off the cpu clock and optionally other clock domains to save power. this is activate d by the sleep instruction, which takes the sleep mode index number as argument. 10.5.6.1 entering and exiting sleep modes the sleep instruction will halt the cpu and all modules belonging to t he stopped clock domains. the modules will be halted regardless of th e bit settings of the mask registers. oscillators and pll?s can also be switched off to save power. these modules have a relatively long start-up time, and are only switched off when very low power consumption is required. the cpu and affected modules are restarted when the sleep mode is exited. this occurs when an interrupt trigge rs, or the wake_n pin is asserted. no te that even though an interrupt is enabled in sleep mode, it may not trigger if the source module is not clocked. table 10-1. maskable module clocks in at32ap7002. bit cpumask hsbmask pbamask pbbmask 0 pico ebi spi0 pm/eic/rtc/wdt 1 - pba spi1 intc 2 - pbb twi hmatrix 3 - hramc usart0 tc0 4 - hsb-hsb bridge usart1 tc1 5 - isi usart2 pwm 6 - usb usart3 7 - lcdc ssc0 8 - ssc1 dac 9 - ssc2 mci 10 - dma pioa ac97c 11 - - piob isi 12 - - pioc usb 13 - - piod smc 14 - - pioe sdramc 15 - - psif ecc 16 - - pdc - 31:17----
102 32054f?avr32?09/09 at32ap7002 10.5.6.2 supported sleep modes the following sleep modes are supported. these are detailed in table 10-2 . ?idle: the cpu is stopped, the rest of the chip is operating. wake-up sources are any interrupt, or wake_n pin. ?frozen: the cpu and hsb modules are stopped, peripherals are operating. wake-up sources are any interr upt from pb modules, or wake_n pin. ?standby: all synchronous clocks are stopped, but oscillators and pll?s are running, allowing quick wake-up to normal mode. wake-up sources are rtc or external interrupt, or wake_n pin. ?stop: as standby, but oscilla tor 0 and 1, and the pll?s are stopped. 32 khz oscillator and rtc/wdt still operates. wake-up sources are rtc or external inte rrupt, or wake_n pin. ?static: all oscillators and clocks are stoppe d. wake-up sources are external interrupt or wake_n pin.? 10.5.6.3 precautions when entering sleep mode modules communicating with external circuits should normally be disabled before entering a sleep mode that will stop the mo dule operation. this prevents erra tic behavior when entering or exiting sleep mode. please refer to the re levant module documentation for recommended actions. communication between the synchronous clock domains is disturbed when entering and exiting sleep modes. this means that bus transactions are not allowed between clock domains affected by the sleep mode. the system may hang if th e bus clocks are stopped in the middle of a bus transaction. the cpu and caches are automatically stopped in a safe state to ensure that all cpu bus oper- ations are complete when the sleep mode goes into effect. thus, when entering idle mode, no further action is necessary. when entering a deeper sleep mode than idle mode, all other hsb masters must be stopped before entering the sleep mode. also, if there is a chance that any pb write operations are incomplete, the cpu should perform a read operation from any register on the pb bus before executing the sleep instruction. this will stal l the cpu while waiting for any pending pb opera- tions to complete. the power manager will normall y turn of all debug related clocks in the system in the static sleep mode, making it impossible for a debugger to communicate with the system. if a table 10-2. sleep modes index sleep mode cpu hsb pba,b + gclk osc0,1 + pll0,1 osc32 + rtc/wdt 0 idle off on on on on 1frozenoffoffononon 2 standby off off off on on 3 stop off off off off on 5 static off off off off off
103 32054f?avr32?09/09 at32ap7002 nexus_access or a memory_access jtag comm and is loaded into th e instruction regis- ter before entering sleep mode some clocks are left running to enable debugging of the system. this will increase the power consumption of the device. if the part entered static mode without a nexus_access ot memory_access instruction lo aded into the jtag instruction register an external reset is the only way for the debugger to get the part out of the sleep mode. when not debugging a program and using sleep modes the jtag should always have the idcode instruction loaded into the jtag instruction register and the ocd system should be disabled. otherwise some clo cks may be left running, incr easing the powe r consumption. 10.5.7 generic clocks timers, communication modules, and other modules connected to external circuitry may require specific clock frequencies to operate correctly . the power manager contains an implementation defined number of generic clocks, that can prov ide a wide range of accurate clock frequencies. each generic clock module runs from either oscilla tor 0 or 1, or pll0 or 1. the selected source can optionally be divided by any even integer up to 512. each clock can be independently enabled and disabled, and is also automatically disabled along with peripheral clocks by the sleep controller. figure 10-4. generic clock generation 10.5.7.1 enabling a generic clock a generic clock is enabled by writi ng the cen bit in gcctrl to 1. each generic clock can use either oscillator 0 or 1 or pll0 or 1 as source, as select ed by the pllsel and oscsel bits. the source clock can optionally be divided by writing diven to 1 and the division factor to div, resulting in the output frequency: f gclk = f src / (2*(div+1)) divider 0 1 osc0 clock pll0 clock pllsel oscsel osc1 clock pll1 clock generic clock div 0 1 diven mask cen sleep controller
104 32054f?avr32?09/09 at32ap7002 10.5.7.2 disabling a generic clock the generic clock can be disabled by writing cen to 0 or entering a sleep mode that disables the pb clocks. in either case, the generic clock will be switched off on the first falling edge after the disabling event, to ensu re that no glitches occur. if cen is written to 0, the bit will still read as 1 until the next falling edge occu rs, and the clock is actually sw itched off. when writing cen to 0, the other bits in gcctrl should not be changed until cen reads as 0, to avoid glitches on the generic clock. when the clock is disabled, both the prescaler and output are reset. 10.5.7.3 changing clock frequency when changing generic clock frequency by writing gcctrl, the clock should be switched off by the procedure above, before being re-enabled with the new clock source or division setting. this prevents glitches during the transition. 10.5.7.4 generic clock implementation in at32ap7002, there are 8 generic clocks. these are allocated to different functions as shown in table 10-3 . 10.5.8 divided pb clocks the clock generator in the power manager pr ovides divided pba and pbb clocks for use by peripherals that require a prescaled pb clock. this is described in the documentation for the rel- evant modules. the divided clocks are not directly maskable, but are stopped in sleep modes where the pb clocks are stopped. 10.5.9 debug operation during a debug session, the user may need to halt the system to inspect memory and cpu reg- isters. the clocks normally keep running during this debug opera tion, but some peripherals may require the clocks to be stopped, e.g. to prevent timer overflow, which would cause the program to fail. for this reason, peripherals on the pba and pbb buses may use ?debug qualified? pb clocks. this is described in t he documentation for the relevant modules. the divided pb clocks are always debug qualified clocks. table 10-3. generic clock allocation clock number function 0gclk0 pin 1gclk1 pin 2gclk2 pin 3gclk3 pin 4gclk4 pin 5 reserved for internal use 6dac 7 lcd controller
105 32054f?avr32?09/09 at32ap7002 debug qualified pb clocks are stopped duri ng debug operation. the debug system can option- ally keep these clocks running during the debug operation. this is described in the documentation for the on-chip debug system.
106 32054f?avr32?09/09 at32ap7002 10.5.10 reset controller the reset controller collects the various reset sources in the system and generates hard and soft resets for the digital logic. the device contains a power-on detector, which keeps the system reset until power is stable. this eliminates the need for external reset circuitry to guarantee stable operation when powering up the device. it is also possible to reset the device by asserting the reset_n pin. this pin has an internal pul- lup, and does not need to be driven externally when negated. table 10-4 lists these and other reset sources supported by the reset controller. figure 10-5. reset controller block diagram reset sources are divided into hard and soft resets. hard resets imply that the system could have become unstable, and virtually all logic will be reset. t he clock generator, which also con- trols the oscillators, will also be reset. if the device is reset due to a power-on reset, or reset occurred when the device was in a sleep mode that disabled the oscillators , the normal oscillator startup time will apply. a soft reset will reset most digital logic in t he device, such as cpu, hsb, and pb modules, but not the ocd system, clock generator, watchdog timer and rtc, allowing some functions, including the oscillators, to remain active during the reset. the startup time from a soft reset is thus negligible. note that all pb registers are reset, except those in the rtc/wdt. the mcctrl and cksel registers are reset, and the devic e will restart using oscillator 0 as clock source for all synchronous clocks. in addition to the listed reset types, the jtag can keep parts of the device statically reset through the jtag reset register. see jtag documentation for details. ntae reset controller reset_n power-on detector dbr watchdog reset rc_rcause hard reset soft reset cpu, hsb, pba, pbb ocd, rtc/wdt clock generato
107 32054f?avr32?09/09 at32ap7002 the cause of the last reset can be read from the rc_rcause register. this register contains one bit for each reset source, and can be identified during the boot sequence of an application to determine the proper action to be taken. table 10-4. reset types reset source description type power-on reset supply voltage below the power-on reset detector threshold voltage hard external reset_n pin asserted hard nanotrace access error see on-chip debug documentation. soft watchdog timer see watchdog timer documentation. soft ocd see on-chip debug documentation soft
108 32054f?avr32?09/09 at32ap7002 10.6 user interface offset register register name access reset 0x00 main clock control mcctrl read/write 0x0 0x04 clock select cksel read/write 0x0 0x08 cpu clock mask cpumask read/write impl. defined 0x0c hsb clock mask hsbmask read/write impl. defined 0x10 pba clock mask pbamask read/write impl. defined 0x14 pbb clock mask pbbmask read/write impl. defined 0x20 pll0 control pll0 read/write 0x0 0x24 pll1 control pll1 read/write 0x0 0x40 interrupt enable ier write-only 0x0 0x44 interrupt disable idr write-only 0x0 0x48 interrupt mask imr read-only 0x0 0x4c interrupt status isr read-only 0x0 0x50 interrupt clear icr write-only 0x0 0x60 generic clock control 0 gcctrl0 read/write 0x0 0x64 generic clock control 1 gcctrl1 read/write 0x0 0x68 generic clock control 2 gcctrl2 read/write 0x0 0x6c generic clock control 3 gcctrl3 read/write 0x0 0x70 generic clock control 4 gcctrl4 read/write 0x0 0x74 generic clock control 5 gcctrl5 read/write 0x0 0x78 generic clock control 6 gcctrl6 read/write 0x0 0x7c generic clock control 7 gcctrl7 read/write 0x0 0x80 - 0xbc reserved 0xc0 reset cause rcause read
109 32054f?avr32?09/09 at32ap7002 10.6.1 main clock control name: mcctrl access type: read/write ? pllsel: pll select 0: oscillator 0 is source for the main clock 1: pll0 is source for the main clock 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------pllsel-
110 32054f?avr32?09/09 at32ap7002 10.6.2 clock select name: cksel access type: read/write ? pbbdiv, pbbsel: pbb divi sion and clock select pbbdiv = 0: pbb clock equals main clock. pbbdiv = 1: pbb clock equals main clock divided by 2 (pbbsel+1) . ? pbadiv, pbasel: pba division and clock select pbadiv = 0: pba clock equals main clock. pbadiv = 1: pba clock equals main clock divided by 2 (pbasel+1) . ? hsbdiv, hsbsel: hsb divi sion and clock select hsbdiv = 0: hsb clock equals main clock. hsbdiv = 1: hsb clock equals main clock divided by 2 (hsbsel+1) . ? cpudiv, cpusel: cpu divi sion and clock select cpudiv = 0: cpu clock equals main clock. cpudiv = 1: cpuclock equals main clock divided by 2 (cpusel+1) . note that if xxxdiv is written to 0, xxxsel should also be written to 0 to ensure correct operation. also note that writing this register clears isr:ckrdy. the register must not be re-written until ckrdy goes high. 31 30 29 28 27 26 25 24 pbbdiv - - - - pbbsel 23 22 21 20 19 18 17 16 pbadiv - - - - pbasel 15 14 13 12 11 10 9 8 hsbdiv - - - - hsbsel 76543210 cpudiv - - - - cpusel
111 32054f?avr32?09/09 at32ap7002 10.6.3 clock mask name: cpu/hsb/pba/pbbmask access type: read/write ? mask: clock mask if bit n is cleared, the clock for module n is stopped. if bit n is set, the clock for module n is enabled according to the cur rent power mode. the number of implemented bits in each mask register, as well as which module clock is controlled by each bit, is implementation dependent. 31 30 29 28 27 26 25 24 mask[31:24] 23 22 21 20 19 18 17 16 mask[23:16] 15 14 13 12 11 10 9 8 mask[15:8] 76543210 mask[7:0]
112 32054f?avr32?09/09 at32ap7002 10.6.4 pll control name: pll0,1 access type: read/write ? plltest: pll test reserved for internal use. always write to 0. ? pllcount: pll count specifies the number of slow clock cycles before isr:lockn will be set after plln has been written, or after plln has been automatically re-enabled after exiting a sleep mode. ? pllmul: pll multiply factor ? plldiv: pll division factor these bitfields determine the ratio of the pll out put frequency to the source oscillator frequency: f pll = (pllmul+1)/(plldiv+1) ? f osc ? pllopt: pll option this field should be written to 100. other values are reserved. ? pllosc: pll os cillator select 0: oscillator 0 is t he source for the pll. 1: oscillator 1 is t he source for the pll. ? pllen: pll enable 0: pll is disabled. 1: pll is enabled. 31 30 29 28 27 26 25 24 plltest - pllcount 23 22 21 20 19 18 17 16 pllmul 15 14 13 12 11 10 9 8 plldiv 76543210 - - - pllopt pllosc pllen
113 32054f?avr32?09/09 at32ap7002 10.6.5 interrupt enable/disable/mask/status/clear name: ier/idr/imr/isr/icr access type: ier/idr/icr: write-only imr/isr: read-only ? mskrdy: mask ready 0: either xxxmask register has b een written, and clocks are not yet enabled or disabled according to the new mask value. 1: clocks are enabled and disabled as indicated in the xxxmask registers. note: writing icr:mskrdy to 1 has no effect. ? ckrdy: clock ready 0: the cksel register has been written, and the new clock setting is not yet effective. 1: the synchronous clocks have frequencies as indicated in the cksel register. note: writing icr:ckrdy to 1 has no effect. ? vmrdy, vok these bits are for internal use only. in isr, the value of thes e bits is undefined. in ier, these bits should be written to 0. ? wake: wake pin asserted 0: the wake_n pin is not asserted, or has been asserted for less than one pb clock period. 1: the wake_n pin is asserted for longer than one pb clock period. ? lock1: pll1 locked ? lock0: pll0 locked 0: the pll is unlocked, and cannot be used as clock source. 1: the pll is locked, and can be used as clock source. the effect of writing or reading the bits listed above depends on which register is being accessed: ? ier (write-only) 0: no effect 1: enable interrupt ? idr (write-only) 0: no effect 1: disable interrupt 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - mskrdy ckrdy vmrdy vok wake lock1 lock0
114 32054f?avr32?09/09 at32ap7002 ? imr (read-only) 0: interrupt is disabled 1: interrupt is enabled ? isr (read-only) 0: an interrupt event has occurred 1: an interrupt even has not occurred ? icr (write-only) 0: no effect 1: clear interrupt event
115 32054f?avr32?09/09 at32ap7002 10.6.6 generic clock control name: gcctrl0... gcctrl7 access type: read/write there is one gcctrl register per generic clock in the design. ? div: division factor ? diven: divide enable 0: the generic clock equals the undivided source clock. 1: the generic clock equals the source clock divided by 2*(div+1). ? cen: clock enable 0: clock is stopped. 1: clock is running. ? pllsel: pll select 0: oscillator is source for the generic clock. 1: pll is source for the generic clock. ? oscsel: oscillator select 0: oscillator (or pll) 0 is source for the generic clock. 1: oscillator (or pll) 1is source for the generic clock. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 div[7:0] 76543210 - - - diven - cen pllsel oscsel
116 32054f?avr32?09/09 at32ap7002 10.6.7 reset cause name: rc_rcause access type: read-only ? serp: serious problem error this bit is set if a reset occured due to a serious prob lem in the cpu, like nanotrace access error, for instance. ? jtag: jtag reset this bit is set if a reset occurred due to a jtag reset. ? wdt: watchdog timer this bit is set if a reset occurred due to a timeout of the watchdog timer. ? ext: external reset this bit is set if a reset occurred due to assertion of the reset_n pin. ? por: power-on detector this bit is set if a reset was caused by the power-on detector. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - serp jtag wdt ext - por
117 32054f?avr32?09/09 at32ap7002 11. real time counter (rtc) rev: 1.0.1.1 11.1 features ? 32-bit real-time counte r with 16-bit prescaler ? clocked from 32 khz oscillator ? high resoluti on: max count frequency 16khz ? long delays ? max timeout 272 years ? extremely low power consumption ? available in all sleep modes except deepdown ? optional wrap at max value ? interrupt on wrap 11.2 description the real time counter (rtc) enables periodic in terrupts at long intervals, or accurate mea- surement of real-time sequences. the rtc is fed from a 16-bit prescaler, which is clocked from the 32 khz oscillator. any tapping of the prescaler can be select ed as clock source for the rtc, enabling both high resolution and long timeouts. the prescaler cannot be written directly, but can be cleared by the user. the rtc can generate an interrupt when the counter wraps around the top value of 0xffffffff. optionally, the rtc can wrap at a lower value, producing accurate periodic interrupts. 11.3 block diagram figure 11-1. real time counter module block diagram 11.4 product dependencies 11.4.1 i/o lines none. 16-bit prescaler 32 khz 32-bit counter rtc_val rtc_top topi irq
118 32054f?avr32?09/09 at32ap7002 11.4.2 power management the rtc is continously clocked, and remains operating in all sleep modes except static. 11.4.3 interrupt the rtc interrupt line is connected to one of the internal sources of the interrupt controller. using the rtc interrupt requires the interrupt controller to be programmed first. 11.4.4 debug operation the rtc prescaler and watchdog timer are frozen during debug operation, unless the ocd sys- tem keeps peripherals running in debug operation. 11.5 functional description 11.5.1 rtc operation 11.5.1.1 source clock the rtc is enabled by writing the en bit in the ctrl register. this also enables the clock for the prescaler. the psel bitfield in the same register selects th e prescaler tapping, selecting the source clock for the rtc: f rtc = 2 -(psel+1) * 32khz note that if the rtc is used in stop mode, psel must be 2 or higher to ensure no ticks are missed when entering or leaving sleep mode. 11.5.1.2 counter operation the rtc count value can be read from or written to the register val. the prescaler cannot be written directly, but can be reset by writing the strobe pclr in ctrl. when enabled, the rtc will then up -count until it reac hes 0xffffffff, and then wrap to 0x0. writing ctrl:topen to one causes the rtc to wrap at the value written to top. the status bit topi in isr is set when this occurs. 11.5.1.3 rtc interrupt writing the topi bit in ier enab les the rtc interr upt, while writing the corresponding bit in idr disables the rtc interrupt. imr can be read to see whether or not the interrupt is enabled. if enabled, an interrupt will be gener ated if the topi flag in isr is set. the flag can be cleared by writing topi in icr to one.
119 32054f?avr32?09/09 at32ap7002 11.6 user interface offset register register name access reset 0x00 rtc control ctrl read/write 0x0 0x04 rtc value val read/write 0x0 0x08 rtc top top read/write 0x0 0x10 rtc interrupt enable ier write-only 0x0 0x14 rtc interrupt disable idr write-only 0x0 0x18 rtc interrupt mask imr read-only 0x0 0x1c rtc interrupt status isr read-only 0x0 0x20 rtc interrupt clear icr write-only 0x0
120 32054f?avr32?09/09 at32ap7002 11.6.1 rtc control name: ctrl access type: read/write ? psel: prescale select selects prescaler bit psel as source clock for the rtc. ? topen: top enable 0: rtc wraps at 0xffffffff 1: rtc wraps at rtc_top ? pclr: prescaler clear writing this strobe clears the prescaler. note that this also resets the watchdog timer. ? en: enable 0: rtc is disabled 1: rtc is enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - psel[3:0] 76543210 - - - - - topen pclr en
121 32054f?avr32?09/09 at32ap7002 11.6.2 rtc value name: val access type: read/write ? val: rtc value this value is incremented on every rising edge of the source clock. 31 30 29 28 27 26 25 24 val[31:24] 23 22 21 20 19 18 17 16 val[23:16] 15 14 13 12 11 10 9 8 val[15:8] 76543210 val[7:0]
122 32054f?avr32?09/09 at32ap7002 11.6.3 rtc top name: top access type: read/write ? top: rtc top value val wraps at this value if ctrl:topen is 1. 31 30 29 28 27 26 25 24 top[31:24] 23 22 21 20 19 18 17 16 top[23:16] 15 14 13 12 11 10 9 8 top[15:8] 76543210 top[7:0]
123 32054f?avr32?09/09 at32ap7002 11.6.4 rtc interrupt enable/disable/mask/status/clear name: ier/idr/imr/isr/icr access type: ier/idr/icr: write-only imr/isr: read-only ? topi: top interrupt val has wrapped at its top. the effect of writing or reading this bit depends on which register is being accessed: ? ier (write-only) 0: no effect 1: enable interrupt ? idr (write-only) 0: no effect 1: disable interrupt ? imr (read-only) 0: interrupt is disabled 1: interrupt is enabled ? isr (read-only) 0: an interrupt event has not occurred 1: an interrupt event has occurred. note that this is only set when the rtc is configured to wrap at top. ? icr (write-only) 0: no effect 1: clear interrupt event 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
124 32054f?avr32?09/09 at32ap7002 12. watchdog timer (wdt) rev: 1.0.1 12.1 features ? watchdog timer with 16-bit prescaler 12.2 description the watchdog timer (wdt) is fed from a 16-bit pr escaler, which is clocked from the 32 khz oscillator. any tapping of the pr escaler can be selected as cloc k source for the wdt.the watch- dog timer must be periodically reset by software within the timeout period, ot herwise, the device is reset and starts executing from the boot vector. this allows the device to recover from a con- dition that has caused the system to be unstable. 12.3 block diagram figure 12-1. real time counter module block diagram 12.4 product dependencies 12.4.1 i/o lines none 12.4.2 power management the wdt is continously clocked, and remains ope rating in all sleep modes. however, if the wdt is enabled and the user tries to enter a sl eepmode where the 32 khz oscillator is turned off the system will enter the stop slee pmode instead. this is to en sure the wdt is still running. 12.4.3 debug operation the watchdog timer is frozen during debug operati on, unless the ocd system keeps peripherals running in debug operation. 16-bit prescaler 32 khz wdt_clr w atchdog detector wdt_ctrl w atchdog reset
125 32054f?avr32?09/09 at32ap7002 12.5 functional description 12.5.1 watchdog timer the wdt is enabled by writing the en bit in the ctrl register. this also enables the clock for the prescaler. the psel bitfield in the same register selects the watchdog ti meout period: t wdt = 2 (psel+1) * 30.518 s to avoid accidental disabling of the watchdog, the ctrl register must be written twice, first with the key field set to 0x55, then 0xaa without changing the other bitfields. failure to do so will cause the write operation to be ignored, and ctrl does not change value. the clr register must be written with any value with regular intervals shorter than the watchdog timeout period. otherwise, the device will receive a soft reset, and the code will start executing from the boot vector.
126 32054f?avr32?09/09 at32ap7002 12.6 user interface 12.6.1 wdt control name: ctrl access type: read/write ? key this bitfield must be written twice, first with key value 0x55, then 0xaa, for a write operation to be effective. this bitfield always reads as zero. ? psel: prescale select prescaler bit psel is used as watchdog ti meout period. ? en: wdt enable 0: wdt is disabled. 1: wdt is enabled. offset register register name access reset 0x30 wdt control ctrl read/write 0x0 0x34 wdt clear clr write-only 0x0 31 30 29 28 27 26 25 24 key[7:0] 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - psel[3:0] 76543210 -------en
127 32054f?avr32?09/09 at32ap7002 12.6.2 wdt clear name: clr access type: write-only when the watchdog timer is enabled, this register must be periodically written, with any value, within the watchdog timeout period, to prevent a watchdog reset.
128 32054f?avr32?09/09 at32ap7002 13. interrupt controller (intc) rev: 1.0.0.4 13.1 features ? autovectored low latency interrupt service with programmable priority ? 4 priority levels for regular, maskable interrupts ? one non-maskable interrupt ? up to 64 groups of interrupts with up to 32 interrupt requests in each group 13.2 overview the intc collects interrupt requests from the peripherals, prioritizes them, and delivers an inter- rupt request and an autovector to the cpu. the avr32 architecture supports 4 priority levels for regular, maskable interrupts, and a non-maskable interrupt (nmi). the intc supports up to 64 groups of interrupts. each group can have up to 32 interrupt request lines, these lines are connected to the peripherals. each group has an interrupt priority register (ipr) and an interrupt request register (irr). the iprs are used to assign a priority level and an autovector to each group, and the irrs are used to identify the active interrupt request within each group. if a group has only one interrupt request line, an active interrupt group uniquely identifies the active interrupt request line, and the corresponding irr is not needed. the intc also provides one interrupt cause register (icr) per priority level. these registers identify the group that has a pending interrupt of the corresponding priority level. if several groups have a pending interrupt of the same level, the group with the lowest number takes priority. 13.3 block diagram figure 13-1 gives an overview of the intc. the grey boxes represent registers that can be accessed via the user interface. the interrupt requests from the peripherals (ireqn) and the nmi are input on the left side of the figure. signals to and from the cpu are on the right side of the figure.
129 32054f?avr32?09/09 at32ap7002 figure 13-1. intc block diagram 13.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 13.4.1 power management if the cpu enters a sleep mode that disables cl ocks used by the intc, the intc will stop func- tioning and resume operation after the system wakes up from sleep mode. 13.4.2 clocks the clock for the intc bus interface (clk_intc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. 13.4.3 debug operation when an external debugger forces the cpu into debug mode, the intc continues normal operation. 13.5 functional description all of the incoming interrupt requests (ireqs) are sampled into the corresponding interrupt request register (irr). the irrs must be accessed to identify which ireq within a group that is active. if several ireqs within the same group are active, the interrupt service routine must prioritize between them. all of the input lines in each group are logically ored together to form the grpreqn lines, indicating if there is a pending interrupt in the corresponding group. the request masking hardware maps each of the grpreq lines to a priority level from int0 to int3 by associating each grou p with the interrupt level (int level) field in the corresponding interrupt priority register (ipr). the grpreq inputs are then masked by the mask bits from the cpu status register. any interrupt group that has a pending interrupt of a priority level that is not masked by the cpu status register, gets its corresponding valreq line asserted. request masking or ireq0 ireq1 ireq2 ireq31 grpreq0 masks sreg masks i[3-0]m gm intlevel autovector prioritizer cpu interrupt controller or grpreqn nmireq or ireq32 ireq33 ireq34 ireq63 grpreq1 irr registers ipr registers icr registers int_level, offset int_level, offset int_level, offset ipr0 ipr1 iprn irr0 irr1 irrn valreq0 valreq1 valreqn . . . . . . . . .
130 32054f?avr32?09/09 at32ap7002 masking of the interrupt requests is done based on five interrupt mask bits of the cpu status register, namely interrupt level 3 mask (i3m) to interrupt level 0 mask (i0m), and global inter- rupt mask (gm). an interrupt request is masked if either the gm or the corresponding interrupt level mask bit is set. the prioritizer hardware uses th e valreq lines and the intlevel fi eld in the iprs to select the pending interrupt of the highest priority. if an nm i interrupt request is pending, it automatically gets the highest priority of any pending interrupt. if several interrupt groups of the highest pend- ing interrupt level have pending interrupts, the interrupt group with the highest number is selected. the intlevel and handler autovector offset (autovector) of the selected interrupt are transmitted to the cpu for interrupt handling an d context switching. the cpu does not need to know which interrupt is requesting handling, but only the level and the offset of the handler address. the irr registers contain the interrupt request lines of the groups and can be read via user interface registers for checking which interrupts of the group are actually active. 13.5.1 non-maskable interrupts a nmi request has priority over all other interrupt requests. nmi has a dedicated exception vec- tor address defined by the avr32 archit ecture, so autovector is undefined when intlevel indicates that an nmi is pending. 13.5.2 cpu response when the cpu receives an interr upt request it checks if any othe r exceptions are pending. if no exceptions of higher priority are pending, interr upt handling is initiated. when initiating interrupt handling, the corresponding interrupt mask bit is se t automatically for this and lower levels in sta- tus register. e.g, if an interrupt of level 3 is approved for handling, the interrupt mask bits i3m, i2m, i1m, and i0m are set in status register. if an interrupt of level 1 is approved, the masking bits i1m and i0m are set in status register. the handler address is calculated by adding autovector to the cpu system register exc eption vector base address (evba). the cpu will then jump to the calculated address and start executing th e interrupt handler. setting the interrupt mask bits prevents the interrupts from the same and lower levels to be passed through the interrupt controller. setting of the same level mask bit prevents also multiple requests of the same interrupt to happen. it is the responsibility of the ha ndler software to clear the interrupt request that caused the inter- rupt before returning from the interrupt handler. if the conditions that caused the interrupt are not cleared, the interrupt request remains active. 13.5.3 clearing an interrupt request clearing of the interrupt request is done by writing to registers in the corresponding peripheral module, which then clears the corresponding nmireq/ireq signal. the recommended way of clearing an interrupt request is a store operation to the controlling peripheral register, followed by a dummy load operat ion from the same register. this causes a pipeline stall, which prevents the interrupt from accidentally re-triggering in case the handler is exited and the interrupt mask is cleared before the interrupt request is cleared.
131 32054f?avr32?09/09 at32ap7002 13.6 user interface table 13-1. intc register memory map offset register register name access reset 0x000 interrupt priority register 0 ipr0 read/write 0x00000000 0x004 interrupt priority register 1 ipr1 read/write 0x00000000 ... ... ... ... ... 0x0fc interrupt priority register 63 ipr63 read/write 0x00000000 0x100 interrupt request register 0 irr0 read-only n/a 0x104 interrupt request register 1 irr1 read-only n/a ... ... ... ... ... 0x1fc interrupt request regi ster 63 irr63 read-only n/a 0x200 interrupt cause register 3 icr3 read-only n/a 0x204 interrupt cause register 2 icr2 read-only n/a 0x208 interrupt cause register 1 icr1 read-only n/a 0x20c interrupt cause register 0 icr0 read-only n/a
132 32054f?avr32?09/09 at32ap7002 13.6.1 interrupt priority registers register name : ipr0...ipr63 access type: read/write offset: 0x000 - 0x0fc reset value: 0x00000000 ? intlevel: interrupt level indicates the evba-relative offs et of the interrup t handler of the co rresponding group: 00: int0 01: int1 10: int2 11: int3 ? autovector: autovector address handler offset is used to give the address of the interrupt handle r. the least significant bit should be written to zero to giv e halfword alignment. 31 30 29 28 27 26 25 24 intlevel[1:0] ------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - autovector[13:8] 76543210 autovector[7:0]
133 32054f?avr32?09/09 at32ap7002 13.6.2 interrupt request registers name : irr0...irr63 access type: read-only offset: 0x0ff - 0x1fc reset value: n/a ? irr: interrupt request line this bit is cleared when no interrupt request is pending on this input request line. this bit is set when an interrupt request is pending on this input request line. the are 64 irrs, one for each group. each irr has 32 bits, one for each possible interrupt request, for a total of 2048 possibl e input lines. the irrs are read by the software interrupt handler in order to determine which interrupt request is pending. the irrs are sampled continuously, and are read-only. 31 30 29 28 27 26 25 24 irr[32*x+31] irr[32*x+30] irr[32*x+ 29] irr[32*x+28] irr[32* x+27] irr[32*x+26] irr[32*x+25] irr[32*x+24] 23 22 21 20 19 18 17 16 irr[32*x+23] irr[32*x+22] irr[32*x+ 21] irr[32*x+20] irr[32* x+19] irr[32*x+18] irr[32*x+17] irr[32*x+16] 15 14 13 12 11 10 9 8 irr[32*x+15] irr[32*x+14] irr[32*x+ 13] irr[32*x+12] irr[32*x+ 11] irr[32*x+10] irr[32*x+9] irr[32*x+8] 76543210 irr[32*x+7] irr[32*x+6] irr[32*x+5] irr[32*x+4] irr[32*x+3] irr[32*x+2] irr[32*x+1] irr[32*x+0]
134 32054f?avr32?09/09 at32ap7002 13.6.3 interrupt cause registers register name : icr0...icr3 access type: read-only offset: 0x200 - 0x20c reset value: n/a ? cause: interrupt group causing interrupt of priority n icrn identifies the group with the highest pr iority that has a pending interrupt of le vel n. this value is only defined when at least one interrupt of level n is pending. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -- cause
135 32054f?avr32?09/09 at32ap7002 14. external interrupt controller (eic) rev: 1.0.0.1 14.1 features ? dedicated interrupt requ ests for each interrupt ? individually maskable interrupts ? interrupt on rising or falling edge ? interrupt on high or low level ? maskable nmi interrupt 14.2 description the external interrupt controller allows 4 pins to be c onfigured as external interrupts. each pin has its own interrupt request, and can be individually masked. each pin can generate an inter- rupt on rising or falling edge, or high or low level. the module also masks the nmi_n pin, which generates the nmi interrupt for the cpu. 14.3 block diagram figure 14-1. external interrupt controller block diagram 14.4 product dependencies 14.4.1 i/o lines the external interrupt and nmi pins are multiplexed with pio lines. to act as external interrupts, these pins must be configured as inputs pins by th e pio controller. it is also possible to trigger the interrupt by driving these pins from registers in the pio controller, or another peripheral out- put connected to the same pin. sync edge/level detector mask irqn extintn intn level mode ier idr icr isr imr nmi_n sync mask nmi_irq nmic
136 32054f?avr32?09/09 at32ap7002 14.4.2 power management edge triggered interrupts are available in al l sleep modes except deepdown. level triggered interrupts and the nmi interrupt are available in all sleep modes. 14.4.3 interrupt the eic interrupt lines are connected to internal sources of the interrupt controller. using the external interrutps requires the interrupt controller to be programmed first. using the non-maskable interrupt does not require the interrupt controller to be programmed. 14.5 functional description 14.5.1 external interrupts each external interrupt pin extintn can be configured to produce an interrupt on rising or fall- ing edge, or high or low level. external interrupts are configured by the mode, edge, and level registers. each interrupt n has a bit intn in each of these registers. similarly, each interrupt has a corresponding bit in each of the interrupt control and status regis- ters. writing 1 to the intn strobe in ier enables the external interrupt on pin extintn, while writing 1 to intn in idr disables the external interrupt. imr can be read to check which inter- rupts are enabled. when the inte rrupt triggers, the corresponding bit in isr will be set. for edge triggered interrupts, the flag remains set until the corresponding strobe bit in icr is written to 1. for level triggered interrupts, the flag remains set for as long as the interrupt condition is present on the pin. writing intn in mode to 0 enables edge triggered interrupts, while writing the bit to 1 enables level triggered interrupts. if extintn is configured as an edge triggered interrupt, writing intn in edge to 0 will trigger the interrupt on falling edge, while writing the bit to 1 will trigger the inte rrupt on ri sing edge. if extintn is configured as a le vel triggered inte rrupt, writing intn in level to 0 will trigger the interrupt on low level, while wr iting the bit to 1 will trigger th e interrupt on high level. 14.5.1.1 synchronization of external interrupts the pin value of the extintn pins is normally sy nchronized to the cpu clo ck, so spikes shorter than a cpu clock cycle are not guaranteed to produce an interrupt. in stop mode, spikes shorter than a 32khz clock cycle are not guaranteed to produce an interrupt. in deepdown mode, only unsynchronized level interr upts remain active, and any short sp ike on this interrupt will wake up the device. 14.5.2 nmi control the non-maskable interrupt of the cpu is connected to the nmi_n pin through masking logic in the external interrupt controller. this masking ensures that the nmi will not trigger before the cpu has been set up to handle interrupts. writing the en bit in the nmic register enables the nmi interrupt, while writing en to 0 disables the nmi interrupt. when enabled, the interrupt trig- gers whenever the nmi_n pin is negated. the nmi_n pin is synchronized the same way as external level interrupts.
137 32054f?avr32?09/09 at32ap7002 14.6 user interface offset register register name access reset 0x00 eic interrupt enable ier write-only 0x0 0x04 eic interrupt disable idr write-only 0x0 0x08 eic interrupt mask imr read-only 0x0 0x0c eic interrupt status isr read-only 0x0 0x10 eic interrupt clear icr write-only 0x0 0x14 external interrupt mode mode read/write 0x0 0x18 external interrupt edge edge read/write 0x0 0x1c external interrupt level level read/write 0x0 0x24 external interrupt nmi control nmic read/write 0x0
138 32054f?avr32?09/09 at32ap7002 14.6.1 eic interrupt enable/disable/mask/status/clear name: ier/idr/imr/isr/icr access type: ier/idr/icr: write-only imr/isr: read-only ? intn: external interrupt n 0: external interrupt has not triggered 1: external interrupt has triggered the effect of writing or reading the bits listed above depends on which register is being accessed: ? ier (write-only) 0: no effect 1: enable interrupt ? idr (write-only) 0: no effect 1: disable interrupt ? imr (read-only) 0: interrupt is disabled 1: interrupt is enabled ? isr (read-only) 0: an interrupt event has occurred 1: an interrupt even has not occurred ? icr (write-only) 0: no effect 1: clear interrupt event 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - int3 int2 int1 int0
139 32054f?avr32?09/09 at32ap7002 14.6.2 external interrupt mode/edge/level name: mode/edge/level access type: read/write ? intn: external interrupt n the bit interpretation is register specific: ? mode 0: interrupt is edge triggered 1: interrupt is level triggered ? edge 0: interrupt triggers on falling edge 1: interrupt triggers on rising edge ? level 0: interrupt triggers on low level 1: interrupt triggers on high level 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - int3 int2 int1 int0
140 32054f?avr32?09/09 at32ap7002 14.6.3 nmi control name: nmic access type: read/write ? en: enable 0: nmi disabled. asserting the nmi pi n does not generate an nmi request. 1: nmi enabled. asserting the nmi pin generate an nmi request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------en
141 32054f?avr32?09/09 at32ap7002 15. hsb bus matrix (hmatrix) rev: 2.0.0.2 15.1 features ? user interface on peripheral bus ? configurable number of masters (up to sixteen) ? configurable number of slaves (up to sixteen) ? one decoder for each master ? three different memory mappin gs for each master (interna l and external boot, remap) ? one remap function for each master ? programmable arbitration for each slave ? round-robin ? fixed priority ? programmable default master for each slave ? no default master ? last accessed default master ? fixed default master ? one cycle latency for the first access of a burst ? zero cycle latency for default master ? one special function register for each slave (not dedicated) 15.2 overview the bus matrix implements a multi-layer bus structure, that enables parallel access paths between multiple high speed bus (hsb) masters and slaves in a system, thus increasing the overall bandwidth. the bus matrix interconnects up to 16 hsb masters to up to 16 hsb slaves. the normal latency to connect a master to a slave is one cycle except for the default master of the accessed slave which is connected directly (zero cycle latency). the bus matrix provides 16 special function registers (sfr) that allow the bus matrix to support application specific features. 15.3 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 15.3.1 clocks the clock for the hmatrix bus interface (clk_hmatrix) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the hmatrix before disabling the clock, to avoid freezing the hmatrix in an undefined state. 15.4 functional description 15.4.1 memory mapping the bus matrix provides one decoder for every hsb master interface. the decoder offers each hsb master several memory mappings. in fact, depending on the product, each memory area
142 32054f?avr32?09/09 at32ap7002 may be assigned to several slaves. booting at the same address while using different hsb slaves (i.e. external ram, internal rom or internal flash, etc.) becomes possible. the bus matrix user interface provides master remap control register (mrcr) that performs remap action for every master independently. 15.4.2 special bus granting mechanism the bus matrix provides some speculative bus granting techniques in order to anticipate access requests from some masters. this mechanism reduc es latency at first access of a burst or single transfer. this bus granting mechanism sets a different default master for every slave. at the end of the current access, if no other re quest is pending, the slave remains connected to its associated default master. a slave can be as sociated with three kinds of default masters: no default master, last access master and fixed default master. 15.4.2.1 no default master at the end of the current access, if no other request is pending, the slave is disconnected from all masters. no default ma ster suits low-power mode. 15.4.2.2 last access master at the end of the current access, if no other re quest is pending, the slave remains connected to the last master that performed an access request. 15.4.2.3 fixed default master at the end of the current access, if no other r equest is pending, the slave connects to its fixed default master. unlike last access master, the fixed master does not change unless the user modifies it by a software action (field fixed_defmstr of the related scfg). to change from one kind of default master to another, the bus matrix user interface provides the slave configuration registers, one for each slave, that set a default master for each slave. the slave configuration register contains two fields: defmstr_type and fixed_defmstr. the 2-bit defmstr_type field selects the default mast er type (no default, last access master, fixed default master), whereas the 4-bit fixed_defmstr field selects a fixed default master pro- vided that defmstr_type is set to fixed default master. please refer to the bus matrix user interface description. 15.4.3 arbitration the bus matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to access the same slave at the same time. one arbiter per hsb slave is provided, thus ar bitrating each slave differently. the bus matrix provides the user with the possibility of choosing between 2 arbitration types for each slave: 1. round-robin arbitration (default) 2. fixed priority arbitration this choice is made via the field arbt of the slave configuration registers (scfg). each algorithm may be complemented by selecting a default master configuration for each slave.
143 32054f?avr32?09/09 at32ap7002 when a re-arbitration must be done, specific conditions apply. see section 15.4.3.1 ?arbitration rules? on page 143 . 15.4.3.1 arbitration rules each arbiter has the ability to arbitrate between two or more different master requests. in order to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitra- tion may only take place during the following cycles: 1. idle cycles: when a slave is not connected to any master or is connected to a master which is not currently accessing it. 2. single cycles: when a slave is currently doing a single access. 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for defined length burst, predicted end of burst matches the size of the transfer but is man- aged differently for undefined length burst. see section ??? on page 143. 4. slot cycle limit: when the slot cycle counter has reached the limit value indicating that the current master access is too long and must be broken. see section ??? on page 143. ? undefined length burst arbitration in order to avoid long slave handling during unde fined length bursts (incr), the bus matrix pro- vides specific logic in order to re-arbitrate before the end of the incr transfer. a predicted end of burst is used as a defined length burst transfer and can be selected from among the following five possibilities: 1. infinite: no predicted end of burst is gen erated and therefore i ncr burst transfer will never be broken. 2. one beat bursts: predicted end of burst is generated at each single transfer inside the incp transfer. 3. four beat bursts: predicted end of burst is generated at the end of each four beat bound- ary inside incr transfer. 4. eight beat bursts: predicted end of burst is generated at the end of each eight beat boundary inside incr transfer. 5. sixteen beat bursts: predicted end of burst is generated at the end of each sixteen beat boundary inside incr transfer. this selection can be done through the field ulbt of the master configuration registers (mcfg). ? slot cycle limit arbitration the bus matrix contains specific logic to break long accesses, such as very long bursts on a very slow slave (e.g., an external low speed memory). at the beginning of the burst access, a counter is loaded with the value previously written in the slot_cycle field of the related slave configuration register (scfg) and decreased at each clock cycle. when the counter reaches zero, the arbiter has the ability to re-arbitrate at the end of the current byte, half word or word transfer.
144 32054f?avr32?09/09 at32ap7002 15.4.3.2 round-robin arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave in a round-robin manner. if two or more master requests arise at the same time, the master with the lowest number is first serviced, then the others are serviced in a round-robin manner. there are three round-robin algorithms implemented: 1. round-robin arbitration without default master 2. round-robin arbitration with last default master 3. round-robin arbitration with fixed default master ? round-robin arbitration without default master this is the main algorithm used by bus matrix arbiters. it allows the bus matrix to dispatch requests from different masters to the same slave in a pure round-robin manner. at the end of the current access, if no other request is pending, the slave is disconnected from all masters. this configuration incurs one latency cycle for the first access of a burst. arbitration without default master can be used for masters that perform significant bursts. ? round-robin arbitration with last default master this is a biased round-robin algorithm used by bus matrix arbiters. it allows the bus matrix to remove the one late ncy cycle for the last master that acce ssed the slave. in fact, at the end of the current transfer, if no other master request is pending, the slave remains connected to the last master that performed the access. other non priv ileged masters still get one latency cycle if they want to access the same slave. this technique can be used for masters that mainly perform single accesses. ? round-robin arbitration with fixed default master this is another biased round-robin algorithm. it a llows the bus matrix arbiters to remove the one latency cycle for the fixed default master per slav e. at the end of the current access, the slave remains connected to its fixed default master. every request attempted by this fixed default mas- ter will not cause any latency whereas other non privileged masters w ill still get one latency cycle. this technique can be used for masters that mainly perform single accesses. 15.4.3.3 fixed priority arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the user. if two or more master requests are active at the same time, the master with the highest priority number is serviced first. if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. for each slave, the priority of each master may be defined through the priority registers for slaves (pras and prbs). 15.4.4 slave and master assignation the index number assigned to bus matrix slav es and masters are described in memories chapter.
145 32054f?avr32?09/09 at32ap7002 15.5 user interface table 15-1. hmatrix register memory map offset register name access reset value 0x0000 master configuration register 0 mcfg0 read/write 0x00000002 0x0004 master configuration register 1 mcfg1 read/write 0x00000002 0x0008 master configuration register 2 mcfg2 read/write 0x00000002 0x000c master configuration register 3 mcfg3 read/write 0x00000002 0x0010 master configuration register 4 mcfg4 read/write 0x00000002 0x0014 master configuration register 5 mcfg5 read/write 0x00000002 0x0018 master configuration register 6 mcfg6 read/write 0x00000002 0x001c master configuration register 7 mcfg7 read/write 0x00000002 0x0020 master configuration register 8 mcfg8 read/write 0x00000002 0x0024 master configuration register 9 mcfg9 read/write 0x00000002 0x0028 master configuration register 10 mcfg10 read/write 0x00000002 0x002c master configuration regi ster 11 mcfg11 read/write 0x00000002 0x0030 master configuration register 12 mcfg12 read/write 0x00000002 0x0034 master configuration register 13 mcfg13 read/write 0x00000002 0x0038 master configuration register 14 mcfg14 read/write 0x00000002 0x003c master configuration regi ster 15 mcfg15 read/write 0x00000002 0x0040 slave configuration register 0 scfg0 read/write 0x00000010 0x0044 slave configuration register 1 scfg1 read/write 0x00000010 0x0048 slave configuration register 2 scfg2 read/write 0x00000010 0x004c slave configuration register 3 scfg3 read/write 0x00000010 0x0050 slave configuration register 4 scfg4 read/write 0x00000010 0x0054 slave configuration register 5 scfg5 read/write 0x00000010 0x0058 slave configuration register 6 scfg6 read/write 0x00000010 0x005c slave configuration register 7 scfg7 read/write 0x00000010 0x0060 slave configuration register 8 scfg8 read/write 0x00000010 0x0064 slave configuration register 9 scfg9 read/write 0x00000010 0x0068 slave configuration register 10 scfg10 read/write 0x00000010 0x006c slave configuration register 11 scfg11 read/write 0x00000010 0x0070 slave configuration register 12 scfg12 read/write 0x00000010 0x0074 slave configuration register 13 scfg13 read/write 0x00000010 0x0078 slave configuration register 14 scfg14 read/write 0x00000010 0x007c slave configuration register 15 scfg15 read/write 0x00000010 0x0080 priority register a for slave 0 pras0 read/write 0x00000000 0x0084 priority register b for slave 0 prbs0 read/write 0x00000000 0x0088 priority register a for slave 1 pras1 read/write 0x00000000
146 32054f?avr32?09/09 at32ap7002 0x008c priority register b for slave 1 prbs1 read/write 0x00000000 0x0090 priority register a for slave 2 pras2 read/write 0x00000000 0x0094 priority register b for slave 2 prbs2 read/write 0x00000000 0x0098 priority register a for slave 3 pras3 read/write 0x00000000 0x009c priority register b for slave 3 prbs3 read/write 0x00000000 0x00a0 priority register a for slave 4 pras4 read/write 0x00000000 0x00a4 priority register b for slave 4 prbs4 read/write 0x00000000 0x00a8 priority register a for slave 5 pras5 read/write 0x00000000 0x00ac priority register b for slave 5 prbs5 read/write 0x00000000 0x00b0 priority register a for slave 6 pras6 read/write 0x00000000 0x00b4 priority register b for slave 6 prbs6 read/write 0x00000000 0x00b8 priority register a for slave 7 pras7 read/write 0x00000000 0x00bc priority register b for slave 7 prbs7 read/write 0x00000000 0x00c0 priority register a for slave 8 pras8 read/write 0x00000000 0x00c4 priority register b for slave 8 prbs8 read/write 0x00000000 0x00c8 priority register a for slave 9 pras9 read/write 0x00000000 0x00cc priority register b for slave 9 prbs9 read/write 0x00000000 0x00d0 priority register a for slave 10 pras10 read/write 0x00000000 0x00d4 priority register b for slave 10 prbs10 read/write 0x00000000 0x00d8 priority register a for slave 11 pras11 read/write 0x00000000 0x00dc priority register b for slave 11 prbs11 read/write 0x00000000 0x00e0 priority register a for slave 12 pras12 read/write 0x00000000 0x00e4 priority register b for slave 12 prbs12 read/write 0x00000000 0x00e8 priority register a for slave 13 pras13 read/write 0x00000000 0x00ec priority register b for slave 13 prbs13 read/write 0x00000000 0x00f0 priority register a for slave 14 pras14 read/write 0x00000000 0x00f4 priority register b for slave 14 prbs14 read/write 0x00000000 0x00f8 priority register a for slave 15 pras15 read/write 0x00000000 0x00fc priority register b for slave 15 prbs15 read/write 0x00000000 0x0100 master remap control register mrcr read/write 0x00000000 0x0110 special function register 0 sfr0 read/write ? 0x0114 special function register 1 sfr1 read/write ? 0x0118 special function register 2 sfr2 read/write ? 0x011c special function register 3 sfr3 read/write ? 0x0120 special function register 4 sfr4 read/write ? 0x0124 special function register 5 sfr5 read/write ? table 15-1. hmatrix register memory map (continued) offset register name access reset value
147 32054f?avr32?09/09 at32ap7002 0x0128 special function register 6 sfr6 read/write ? 0x012c special function register 7 sfr7 read/write ? 0x0130 special function register 8 sfr8 read/write ? 0x0134 special function register 9 sfr9 read/write ? 0x0138 special function register 10 sfr10 read/write ? 0x013c special function register 11 sfr11 read/write ? 0x0140 special function register 12 sfr12 read/write ? 0x0144 special function register 13 sfr13 read/write ? 0x0148 special function register 14 sfr14 read/write ? 0x014c special function register 15 sfr15 read/write ? table 15-1. hmatrix register memory map (continued) offset register name access reset value
148 32054f?avr32?09/09 at32ap7002 15.5.1 master configuration registers name: mcfg0...mcfg15 access type: read/write offset: 0x00 - 0x3c reset value: 0x00000002 ? ulbt: undefined length burst type 0: infinite length burst no predicted end of burst is generated and therefore i ncr bursts coming from this master cannot be broken. 1: single access the undefined length burst is treated as a su ccession of single accesses, allowing re-a rbitration at each beat of the incr burs t. 2: four beat burst the undefined length burst is split into a four-beat bu rst, allowing re-arbitration at each four-beat burst end. 3: eight beat burst the undefined length burst is split into an eight-beat bu rst, allowing re-arbitration at each eight-beat burst end. 4: sixteen beat burst the undefined length burst is split into a sixteen-beat bu rst, allowing re-arbitration at each sixteen-beat burst end. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????? ulbt
149 32054f?avr32?09/09 at32ap7002 15.5.2 slave configuration registers name: scfg0...scfg15 access type: read/write offset: 0x40 - 0x7c reset value: 0x00000010 ? arbt: arbitration type 0: round-robin arbitration 1: fixed priority arbitration ? fixed_defmstr: fixed default master this is the number of the default master for this slave. only used if defmstr_type is 2. sp ecifying the number of a master which is not connected to the selected slave is equivalent to sett ing defmstr_type to 0. the size of this field depends on the number of masters. this size is log2(number of masters). ? defmstr_type: default master type 0: no default master at the end of the current slave access, if no other master r equest is pending, the slave is disconnected from all masters. this results in a one cycle latenc y for the first access of a burst transfer or for a single access. 1: last default master at the end of the current slave access, if no other master req uest is pending, the slave stays connected to the last master hav ing accessed it. this results in not having one cycle latency when the last master tries to access the slave again. 2: fixed default master at the end of the current slave access, if no other master request is pending, the slav e connects to the fixed master the numbe r that has been written in the fixed_defmstr field. this results in not having one cycle latency when the fixed master tries to access the slave again. ? slot_cycle: maximum number of allowed cycles for a burst when the slot_cycle limit is reached for a burst, it may be broken by another master trying to access this slave. this limit has been placed to avoid locking a very slow slave when very long bursts are used. this limit must not be very small. unreas onably small values break every burst and the bus matrix arbitrates without performing any data transfer. 16 cycles is a reasonable value for slot_cycle. 31 30 29 28 27 26 25 24 ???????arbt 23 22 21 20 19 18 17 16 ? ? fixed_defmstr defmstr_type 15 14 13 12 11 10 9 8 ???????? 76543210 slot_cycle
150 32054f?avr32?09/09 at32ap7002 15.5.3 bus matrix priority registers a for slaves name: pras0...pras15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 m7pr m6pr 23 22 21 20 19 18 17 16 m5pr m4pr 15 14 13 12 11 10 9 8 m3pr m2pr 76543210 m1pr m0pr
151 32054f?avr32?09/09 at32ap7002 15.5.4 priority registers b for slaves name: prbs0...prbs15 access type: read/write offset: - reset value: 0x00000000 ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 m15pr m14pr 23 22 21 20 19 18 17 16 m13pr m12pr 15 14 13 12 11 10 9 8 m11pr m10pr 76543210 m9pr m8pr
152 32054f?avr32?09/09 at32ap7002 15.5.5 master remap control register name: mrcr access type: read/write offset: 0x100 reset value: 0x00000000 ? rcb: remap command bit for master x 0: disable remapped address decoding for the selected master 1: enable remapped address decoding for the selected master 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rcb15 rcb14 rcb13 rcb12 rcb11 rcb10 rcb9 rcb8 76543210 rcb7 rcb6 rcb5 rcb4 rcb3 rcb2 rcb1 rcb0
153 32054f?avr32?09/09 at32ap7002 15.5.6 special function registers name: sfr0...sfr15 access type: read/write offset: 0x110 - 0x115 reset value: - ? sfr: special function register fields those registers are not a hmatrix spec ific register. the field of those will be defined where they are used. 31 30 29 28 27 26 25 24 sfr 23 22 21 20 19 18 17 16 sfr 15 14 13 12 11 10 9 8 sfr 76543210 sfr
154 32054f?avr32?09/09 at32ap7002 16. external bus interface (ebi) rev: 1.0.1.2 16.1 features ? optimized for application memory space support ? integrates three external memory controllers: ? static memory controller ? sdram controller ? ecc controller ? additional logic for nand flash/smartmedia tm and compactflash tm support ? nand flash support: 8-bit as well as 16-bit devices are supported ? compactflash support: all modes (attribute memory, common memory, i/o, true ide) are supported but the signal s _iois16 (i/o and true ide modes) and _ata sel (true ide mode) are not handled. ? optimized external bus: ?16-bit data bus ? up to 23-bit address bus, up to 8-mbytes addressable ? optimized pin multiplexing to redu ce latencies on external memories ? up to 6 chip selects, configurable assignment: ? static memory controller on ncs0 ? sdram controller or static memory controller on ncs1 ? static memory controller on ncs3, optional nand flash support 16.2 description the external bus interface (ebi) is designed to ensure the successful data transfer between several external devices and the embedded memory controller of an avr32 device. the static memory, sdram and ecc controllers are all featured external memory controllers on the ebi. these external memory controllers are capable of handling several types of external memory and peripheral devices, such as sram , prom, eprom, eeprom, flash, and sdram. the ebi also supports the compactflash and the nand flash/smartmedia protocols via inte- grated circuitry that greatly reduces the requirements for external components. furthermore, the ebi handles data transfers with up to six external devices, each assigned to six address spaces defined by the embedded memory controller. data transfers are performed through a 16-bit data bus, an address bus of up to 23 bits, up to three chip select lines (ncs[1:0] and ncs3) and several control pins that are generally mult iplexed between the different external memory controllers.
155 32054f?avr32?09/09 at32ap7002 16.3 block diagram 16.3.1 external bus interface figure 16-1 shows the organization of the external bus interface. figure 16-1. organization of the external bus interface external bus interface 0 d[15:0] a[15:2], a[22:18] mux logic user int erface ch i p sel ect assi g n or st at i c memory controller sd ra m controller bu s mat r i x per i p h er al bu s hsb address decoders a16/ ba0 a0/ nbs0 a1/ nwr2/ nbs2 a17/ ba1 ncs0 ncs3/ nandcs nrd/ noe/ cfoe ncs1/sdcs nwr0/ nwe/ cfwe nwr1/ nbs1/ cfior nwr3/ nbs3/ cfio w sd ck sd cke ra s cas sd we sd a 1 0 nandoe nandwe nand flash sm ar t m e d i a logic ecc controller
156 32054f?avr32?09/09 at32ap7002 16.4 i/o lines description depending on the memory controller in use, all signals are not connected directly through the mux logic. table 16-1. ebi i/o lines description name function type active level ebi d0 - d15 data bus i/o a0 - a23 address bus output smc ncs0, ncs1, ncs3 chip select lines output low nwr0 - nwr3 write signals output low noe output enable output low nrd read signal output low nwe write enable output low nbs0 - nbs3 byte mask signals output low ebi for nand flash/smartmedia support nandcs nand flash chip select line output low nandoe nand flash output enable output low nandwe nand flash write enable output low sdram controller sdck sdram clock output sdcke sdram clock enable output high sdcs sdram controller chip select line output low ba0 - ba1 bank select output sdwe sdram write enable output low ras - cas row and column signal output low nwr0 - nwr3 write signals output low nbs0 - nbs3 byte mask signals output low sda10 sdram address 10 line output
157 32054f?avr32?09/09 at32ap7002 table 16-2 on page 157 details the connections between the two memory controllers and the ebi pins. table 16-2. ebi pins and memory controllers i/o lines connections ebi pins sdramc i/o lines smc i/o lines nwr1/nbs1/cfior nbs1 nwr1/nub a0/nbs0 not supported smc_a0/nlb a1/nbs2/nwr2 not supported smc_a1 a[11:2] sdramc_a[9:0] smc_a[11:2] sda10 sdramc_a10 not supported a12 not supported smc_a12 a[14:13] sdramc_a[12:11] smc_a[14:13] a[22:15] not supported smc_a[22:15] a[25:23] not supported smc_a[25:23] d[15:0] d[15:0] d[15:0]
158 32054f?avr32?09/09 at32ap7002 16.5 application example 16.5.1 hardware interface table 16-3 on page 158 details the connections to be applied between the ebi pins and the external devices for each memory controller. note: 1. nwr1 enables upper byte writes. nwr0 enables lower byte writes. 2. table 16-3. ebi pins and external static devices connections signals pins of the interfaced device 8-bit static device 2 x 8-bit static devices 16-bit static device controller smc d0 - d7 d0 - d7 d0 - d7 d0 - d7 d8 - d15 ? d8 - d15 d8 - d15 a0/nbs0 a0 ? nlb a1/nwr2/nbs2 a1 a0 a0 a2 - a22 a[2:22] a[1:21] a[1:21] ncs0 cs cs cs ncs1/sdcs cs cs cs ncs3/nandcs cs cs cs nrd/noe/cfoe oe oe oe nwr0/nwe we we (1) we nwr1/nbs1 ? we (1) nub nwr3/nbs3 ? ? ?
159 32054f?avr32?09/09 at32ap7002 table 16-4. ebi pins and external devices connections signals pins of the interfaced device sdram smart media or nand flash controller sdramc smc d0 - d7 d0 - d7 ad0-ad7 d8 - d15 d8 - d15 ad8-ad15 a0/nbs0 dqm0 ? a1/nwr2/nbs2 dqm2 ? a2 - a10 a[0:8] ? a11 a9 ? sda10 a10 ? a12 ? ? a13 - a14 a[11:12] ? a15 ? ? a16/ba0 ba0 ? a17/ba1 ba1 ? a18 - a20 ? ? a21 ? cle (3) a22 ? ale (3) ncs0 ? ? ncs1/sdcs cs[0] ? ncs2 ? ? nandcs ? ? ncs3/nandcs ? ? nandoe ? oe nandwe ? we nrd/noe/cfoe ? ? nwr0/nwe/cfwe ? ? nwr1/nbs1/cfior dqm1 ? nwr3/nbs3/cfiow dqm3 ? sdck clk ? sdcke cke ? ras ras ? cas cas ? sdwe we ?
160 32054f?avr32?09/09 at32ap7002 note: 1. not directly connected to t he compactflash slot. permits the co ntrol of the bidirectional buffer between the ebi data bus a nd the compactflash slot. 2. any pio line. 3. the cle and ale signals of the nand flash device may be driven by any address bit. for details, see ?smartmedia and nand flash support? on page 163 . pxx (2) ?? pxx (2) ?ce pxx (2) ?rdy table 16-4. ebi pins and external devices connections (continued) signals pins of the interfaced device sdram smart media or nand flash controller sdramc smc
161 32054f?avr32?09/09 at32ap7002 16.5.2 connection examples figure 16-2 shows an example of connections be tween the ebi and external devices. figure 16-2. ebi connections to memory devices ebi d0-d15 a2-a15 ras cas sdck sdcke sdwe a0/nbs0 2m x 8 sdra m d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 ncs1/sdcs d0-d7 d8-d15 a16/ba0 a17/ba1 a18-a22 a10 sda10 sda10 a2-a11, a13 ncs0 ncs3 a16/ba0 a17/ba1 2m x 8 sdra m d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 nbs0 nbs1 nrd/noe nwr0/nwe 128k x 8 sra m 128k x 8 sra m d0-d7 d0-d7 a0-a16 a0-a16 a1-a17 a1-a17 cs cs oe we d0-d7 d8-d15 oe we nrd/noe a0/nwr0/nbs0 nrd/noe nwr1/nbs1 sdwe sdwe
162 32054f?avr32?09/09 at32ap7002 16.6 product dependencies 16.6.1 i/o lines the pins used for interfacing the external bus interface may be multiplexed with the pio lines. the programmer must first program the pio controller to assign the external bus interface pins to their peripheral function. if i/o lines of the external bus interface are not used by the applica- tion, they can be used for other purposes by the pio controller. 16.7 functional description the ebi transfers data between the internal hsb bus (handled by the hmatrix) and the external memories or peripheral devices. it controls the waveforms and the parameters of the external address, data and control busses and is composed of the following elements: ? the static memory controller (smc) ? the sdram controller (sdramc) ? the ecc controller (ecc) ? a chip select assignment feature that assigns an hsb address space to the external devices ? a multiplex controller circuit that shares the pins between the different memory controllers ? programmable smartmedia and nand flash support logic 16.7.1 bus multiplexing the ebi offers a complete set of control signals that share the 16-bit data lines, the address lines of up to 23 bits and the control signals through a multiplex logic operating in function of the memory area requests. multiplexing is specifically organized in or der to guarantee the maintenance of the address and output control lines at a stable state while no ex ternal access is being pe rformed. mult iplexing is also designed to respect the data float times defined in the memory controllers. furthermore, refresh cycles of the sdram are executed independently by the sdram controller without delaying the other external memory controller accesses. 16.7.2 pull-up control a specific hmatrix_sfr register in the matrix user interface permit enabling of on-chip pull-up resistors on the data bu s lines not multiplexed with the pio controller lines. for details on this register, refer to the peripherals section. the pull-up resistors are enabled after reset. setting the ebi_dbpuc bit disables the pull-up resistors on lines not muxed with pio. enabling the pull- up resistor on lines multiplexed with pio lines can be performed by programming the appropri- ate pio controller. 16.7.3 static memory controller for information on the static memory controller, refer to the static memory controller section. 16.7.4 sdram controller for information on the sdram contro ller, refer to the sdram section. 16.7.5 ecc controller for information on the ecc contro ller, refer to the ecc section.
163 32054f?avr32?09/09 at32ap7002 16.7.6 smartmedia and nand flash support the external bus interface integrates circuitry that interfaces to smartmedia and nand flash devices. the nand flash logic is driven by the static memory controller on the ncs3 address space. programming the ebi_cs3a field in a specific hmatrix_sfr register to the appropriate value enables the nand flash logic. for details on this register, refer to the peripherals section. access to an external nand flash device is then made by accessing the address space reserved to ncs3 (i.e., between 0x0c00 0000 and 0x0fff ffff). the nand flash logic drives the read and write command signals of the smc on the nandoe and nandwe signals when the ncs3 signal is active. nandoe and nandwe are invalidated as soon as the transfer address fails to lie in the ncs3 address space. see figure ?nand flash signal multiplexing on ebi pins? on page 163 for more informations. fo r details on these wave- forms, refer to the static memory controller section. the smartmedia device is connected the same way as the nand flash device. figure 16-3. nand flash signal multiplexing on ebi pins 16.7.6.1 nand flash signals the address latch enable and command latch enable signals on the nand flash device are driven by address bits a22 and a21 of the ebi a ddress bus. the user should note that any bit on the ebi address bus can also be used for this purpose. the command, address or data words on the data bus of the nand flash device are di stinguished by using their address within the ncsx address space. the chip enable (ce) signal of the device and the ready/busy (r/b) sig- nals are connected to pio lines. the ce signal then remains asserted even when ncsx is not selected, preventing the device from returning to standby mode. smc nrd_noe nwr0_nwe nandoe nandwe smartmedia logic ncsx nandwe nandoe
164 32054f?avr32?09/09 at32ap7002 figure 16-4. nand flash application example note: the external bus interfaces is also able to support 16-bits devices. d[7:0] ale nandwe nandoe noe nwe a[22:21] cle ad[7:0] pio r/b ebi ce smartmedia pio ncsx/nandcs not connected
165 32054f?avr32?09/09 at32ap7002 17. dma controller (dmaca) rev: 2.0.0.6 17.1 features ? 2 hsb master interfaces ? 3 channels ? software and hardware handshaking interfaces ? 11 hardware handshaking interfaces ? memory/non-memory periph erals to memory/non-mem ory peripherals transfer ? single-block dma transfer ? multi-block dma transfer ? linked lists ? auto-reloading ? contiguous blocks ? dma controller is always the flow controller ? additional features ? scatter and gather operations ? channel locking ? bus locking ? fifo mode ? pseudo fly-by operation 17.2 overview the dma controller (dmaca) is an hsb-central dma controller core that transfers data from a source peripheral to a destination peripheral over one or more system bus. one channel is required for each source/destination pair. in the most basic configuration, the dmaca has one master interface and one channel. the master interface reads the data from a source and writes it to a destination. two system bus transfers are required for each dma data transfer. this is also known as a dual-access transfer. the dmaca is programmed via the hsb slave interface.
166 32054f?avr32?09/09 at32ap7002 17.3 block diagram figure 17-1. dma controller (dmaca) block diagram 17.4 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 17.4.1 i/o lines the pins used for interfacing the compliant exte rnal devices may be multiplexed with gpio lines. the user must first program the gpio controlle r to assign the dmaca pins to their peripheral functions. 17.4.2 power management to prevent bus errors the dmaca operation must be terminated before entering sleep mode. 17.4.3 clocks the clk_dmaca to the dmaca is generated by the power manager (pm). before using the dmaca, the user must ensure that the dmaca clock is enabled in the power manager. 17.4.4 interrupts the dmaca interface has an interrupt line connect ed to the interrupt controller. handling the dmaca interrupt requires programming the inte rrupt controller before configuring the dmaca. 17.4.5 peripherals both the source peripheral and the destination peripheral must be set up correctly prior to the dma transfer. hsb slave i/f hsb master i/f cfg interrupt generator fifo channel 0 src fsm dst fsm channel 1 dma controller irq_dma hsb slave hsb master
167 32054f?avr32?09/09 at32ap7002 17.5 functional description 17.5.1 basic definitions source peripheral: device on a system bus layer from where the dmaca reads data, which is then stored in the channel fifo. the source peripheral teams up with a destination peripheral to form a channel. destination peripheral: device to which the dmaca writes the stored data from the fifo (pre- viously read from the source peripheral). memory: source or destination that is always ?ready? for a dma transfer and does not require a handshaking interface to interact with the dmaca. a peripheral should be assigned as memory only if it does not insert more than 16 wait states. if more than 16 wait states are required, then the peripheral should use a handshaking interface (the default if the peripheral is not pro- grammed to be memory) in order to signal when it is ready to accept or supply data. channel: read/write datapath between a source peripheral on one configured system bus layer and a destination peripheral on the same or different system bus layer that occurs through the channel fifo. if the source peripheral is not memory, then a source handshaking interface is assigned to the channel. if the destination pe ripheral is not memory, then a destination hand- shaking interface is assigned to the channel. so urce and destination handshaking interfaces can be assigned dynamically by programming the channel registers. master interface: dmaca is a master on the hsb bus reading data from the source and writing it to the destination over the hsb bus. slave interface: the hsb interface over which the dmaca is programmed. the slave interface in practice could be on the same layer as any of the master interfaces or on a separate layer. handshaking interface: a set of signal registers that conform to a protocol and handshake between the dmaca and source or destination peripheral to control the transfer of a single or burst transaction between them. this interface is used to request, acknowledge, and control a dmaca transaction. a channel can receive a request through one of three types of handshaking interface: hardware, software, or peripheral interrupt. hardware handshaking interface: uses hardware signals to control the transfer of a single or burst transaction between the dmaca and the source or destination peripheral. software handshaking interface: uses software registers to control the transfer of a single or burst transaction between the dmaca and the so urce or destination peripheral. no special dmaca handshaking signals are needed on the i/o of the peripheral. this mode is useful for interfacing an existing peripheral to the dmac a without modifying it. peripheral interrupt handshaking interface: a simple use of the hardware handshaking inter- face. in this mode, the interrupt line from the peripheral is tied to the dma_req input of the hardware handshaking interface. other interface signals are ignored. flow controller: the device (either the dmaca or sour ce/destination peripheral) that deter- mines the length of and terminates a dma block transfer. if the length of a block is known before enabling the channel, then the dmaca should be programmed as the flow controller. if the length of a block is not known prior to enabling the channel, the source or destination peripheral needs to terminate a block transfer. in this mode, the peripheral is the flow controller. flow control mode (cfgx.fcmode): special mode that only applies when the destination peripheral is the flow controller. it controls the pre-fetching of data from the source peripheral.
168 32054f?avr32?09/09 at32ap7002 transfer hierarchy: figure 17-2 on page 168 illustrates the hierarchy between dmaca trans- fers, block transfers, transactions (single or burst), and system bus transfers (single or burst) for non-memory peripherals. figure 17-3 on page 168 shows the transfer hierarchy for memory. figure 17-2. dmaca transfer hierarchy for non-memory peripheral figure 17-3. dmaca transfer hierarchy for memory block: a block of dmaca data. the amount of data (block length) is determined by the flow controller. for transfers between the dmaca and memory, a block is broken directly into a sequence of system bus bursts and single transfers. for transfers between the dmaca and a non-memory peripheral, a block is broken into a sequence of dmaca transactions (single and bursts). these are in turn broken into a sequence of system bus transfers. transaction: a basic unit of a dmaca transfer as dete rmined by either the hardware or soft- ware handshaking interface. a tr ansaction is only relevant for transfers between the dmaca and a source or destination peripheral if the source or destination peripheral is a non-memory device. there are two types of transactions: single and burst. dmac transfer dma transfer level block block block block transfer level burst transaction burst transaction burst transaction single transaction dma transaction level burst transfer system bus burst transfer system bus burst transfer system bus single transfer system bus system bus transfer level single transfer system bus dmac transfer dma transfer level block block block block transfer level burst transfer system bus burst transfer system bus burst transfer system bus single transfer system bus system bus transfer level
169 32054f?avr32?09/09 at32ap7002 ? single transaction: the length of a single transaction is always 1 and is converted to a single system bus transfer. ? burst transaction: the length of a burst transaction is programmed into the dmaca. the burst transaction is converted into a sequence of system bus bursts and single transfers. dmaca executes each burst transfer by performing incremental bursts that are no longer than the maximum system bus burst size set. the burst transaction length is under program control and normally bears some relationship to the fifo sizes in the dmaca and in the source and destination peripherals. dma transfer: software controls the number of blocks in a dmaca transfer. once the dma transfer has completed, then hardware within the dmaca disables the channel and can gener- ate an interrupt to signal the completion of the dma transfer. you can then re-program the channel for a new dma transfer. single-block dma transfer: consists of a single block. multi-block dma transfer: a dma transfer may consist of mu ltiple dmaca blocks. multi-block dma transfers are supported through block chaining (linked list pointers), auto-reloading of channel registers, and contiguous blocks. the source and destination can independently select which method to use. ? linked lists (block chaining) ? a linked list pointer (llp) points to the location in system memory where the next linked list item (lli) exists. the lli is a set of registers that describe the next block (block descriptor) and an llp register. the dmaca fetches the lli at the beginning of every block when block chaining is enabled. ? auto-reloading ? the dmaca automatically reloads the channel registers at the end of each block to the value when the channel was first enabled. ? contiguous blocks ? where the address between successive blocks is selected to be a continuation from the end of the previous block. scatter: relevant to destination transfers within a block. the destination system bus address is incremented or decremented by a programmed amount -the scatter increment- when a scatter boundary is reached. the destination system bu s address is incremented or decremented by the value stored in the destination scatter increment (dsrx.dsi) field, multiplied by the number of bytes in a single hsb transfer to the destination (decoded value of ctlx.dst_tr_width)/8. the number of destination transfers between successive scatter boundaries is programmed into the destination scatter count (dsc ) field of the dsrx register. scatter is enabled by writing a ?1? to the ctlx.dst_scatter_en bit. the ctlx.dinc field determines if the address is incremented, decremented or remains fixed when a scatter bound- ary is reached. if the ctlx.dinc field indi cates a fixed-address control throughout a dma transfer, then the ctlx.dst_scatter_en bit is ignored, and the scatter feature is automati- cally disabled. gather: relevant to source transfers within a block. the source system bus address is incre- mented or decremented by a programmed amount when a gather boundary is reached. the number of system bus transfers between successive gather boundaries is programmed into the source gather count (sgrx.sgc) field. the source address is incremented or decremented by the value stored in the source gather increment (sgrx.sgi) field multiplied by the number of bytes in a single hsb transfer from the source -(decoded value of ctlx.src_tr_width)/8 - when a gather boundary is reached. gather is enabled by writing a ?1? to the ctlx.src_gather_en bit. the ctlx.sinc field determines if the address is incremented, decremented or remains fixed when a gather bound-
170 32054f?avr32?09/09 at32ap7002 ary is reached. if the ctlx.sinc field indicates a fixed-address control throughout a dma transfer, then the ctlx.src_gather_en bit is ignored and the gather feature is automatically disabled. note: for multi-block transfers, the counters that keep track of the number of transfer left to reach a gather/scatter boundary are re-initialized to the source gather count (sgrx.sgc) and destination scatter count (dsrx.dsc), respecti vely, at the start of each block transfer. figure 17-4. destination sc atter transfer d11 d10 d9 d8 d7 d6 d5 d4 d3 d2 d1 d0 0 x 080 system memory a0 + 0x218 a0 + 0x210 a0 + 0x208 a0 + 0x200 a0 + 0x118 a0 + 0x110 a0 + 0x108 a0 + 0x100 scatter increment a0 + 0x018 a0 + 0x010 a0 + 0x008 a0 scatter increment 0 x 080 scatter boundary a0 + 0x220 scatter boundary a0 + 0x120 scatter boundary a0 + 0x020 data stream d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 d11 d8 d7 d4 d3 d0 dsr.dsi * 8 = 0x80 (scatter increment in bytes) ctlx.dst_tr_width = 3'b011 (64bit/8 = 8 bytes) dsr.dsi = 16 dsr.dsc = 4
171 32054f?avr32?09/09 at32ap7002 figure 17-5. source gather transfer channel locking: software can program a channel to keep the hsb master interface by locking the arbitration for the master bus interface for the duration of a dma transfer, block, or transac- tion (single or burst). bus locking: software can program a channel to maintain control of the system bus bus by asserting hlock for the duration of a dma transfer, block, or transaction (single or burst). chan- nel locking is asserted for the duration of bus locking at a minimum. fifo mode: special mode to improve bandwidth. when enabled, the channel waits until the fifo is less than half full to fetch the data from the source peripheral and waits until the fifo is greater than or equal to half full to send data to the destination peripheral. thus, the channel can transfer the data using system bus bursts, eliminating the need to arbitrate for the hsb master interface for each single system bus transfer. when this mode is not enabled, the channel only waits until the fifo can transmit/accept a single system bus transfer before requesting the master bus interface. pseudo fly-by operation: typically, it takes two system bu s cycles to complete a transfer, one for reading the source and one for writing to the destination. however, when the source and des- tination peripherals of a dma transfer are on differ ent system bus layers, it is possible for the dmaca to fetch data from the source and store it in the channel fifo at the same time as the dmaca extracts data from the channel fifo and writes it to the destination peripheral. this activity is known as pseudo fly-by operation . for this to occur, the master interface for both source and destination layers must win arbitration of their hsb layer. similarly, the source and destination peripherals must win ownership of their respective master interfaces. d11 d10 d9 d8 system memory a0 + 0x034 a0 + 0x030 a0 + 0x02c a0 + 0x028 d11 d8 d7 d4 a0 + 0x020 a0 + 0x01c a0 + 0x018 a0 + 0x014 d7 d6 d5 d4 d3 d2 d1 d0 a0 + 0x00c a0 + 0x008 a0 + 0x004 a0 d3 d0 gather boundary a0 + 0x24 gather increment = 4 data stream d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d10 d11 gather boundary a0 + 0x38 gather increment = 4 gather boundary a0 + 0x10 gather increment = 4 sgr.sgi * 4 = 0x4 (gather increment in bytes) ctlx.src_tr_width = 3'b010 (32bit/8 = 4 bytes) sgr.sgi = 1 sgr.sgc = 4
172 32054f?avr32?09/09 at32ap7002 17.6 arbitration for h sb master interface each dmaca channel has two request lines that request ownership of a particular master bus interface: channel source and channel destination request lines. source and destination arbitrate separately fo r the bus. once a source/destination state machine gains ownership of the master bus inte rface and the master bus interface has owner- ship of the hsb bus, then hsb transfers can proceed between the peripheral and the dmaca. an arbitration scheme decides which of t he request lines (2 * dmah_num_channels) is granted the particular master bus interface. each channel has a programmable priority. a request for the master bus interface can be made at any time, but is granted only after the cur- rent hsb transfer (burst or single) has completed. therefore, if the master interface is transferring data for a lower priority channel and a higher priority channel requests service, then the master interface will complete the current burst for the lower priority channel before switch- ing to transfer data for the higher priority channel. if only one request line is active at the highest priority level, then the request with the highest pri- ority wins ownership of the hsb master bus interface; it is not necessary for the priority levels to be unique. if more than one request is active at the highest requesting priority, then these competing requests proceed to a second tier of arbitration: if equal priority requests occur, then the lower-numbered channel is granted. in other words, if a peripheral request attached to channel 7 and a peripheral request attached to channel 8 have the same priority, then the peripheral attached to channel 7 is granted first. 17.7 memory peripherals figure 17-3 on page 168 shows the dma transfer hierarchy of the dmaca for a memory periph- eral. there is no handshaking interface with the dmaca, and therefore the memory peripheral can never be a flow controller. once the channel is enabled, the transfer proceeds immediately without waiting for a transaction request. the alternative to not having a transaction-level hand- shaking interface is to allow the dmaca to attempt system bus transfers to the peripheral once the channel is enabled. if the peripheral slave cannot accept these system bus transfers, it inserts wait states onto the bus until it is ready; it is not recommended that more than 16 wait states be inserted onto the bus. by using the handshaking interface, the peripheral can signal to the dmaca that it is ready to transmit/receive data, and then the dmaca can access the peripheral without the peripheral inserting wait states onto the bus. 17.8 handshaking interface handshaking interfaces are used at the transactio n level to control the flow of single or burst transactions. the operation of the handshaking interface is different and depends on whether the peripheral or the dmaca is the flow controller. the peripheral uses the handshaking interface to indi cate to the dmaca that it is ready to trans- fer/accept data over the system bus. a non-memory peripheral can request a dma transfer through the dmaca using one of two handshaking interfaces: ? hardware handshaking ? software handshaking
173 32054f?avr32?09/09 at32ap7002 software selects between the hardware or software handshaking interface on a per-channel basis. software handshaking is accomplished through memory-mapped registers, while hard- ware handshaking is accomplished usin g a dedicated handshaking interface. 17.8.1 software handshaking when the slave peripheral requires the dmaca to perform a dma transaction, it communicates this request by sending an interrupt to the cpu or interrupt controller. the interrupt service routine then uses the software registers to initiate and control a dma trans- action. these software registers are used to implement the software handshaking interface. the hs_sel_src/hs_sel_dst bit in the cfgx channel configuration register must be set to enable software handshaking. when the peripheral is not the flow controller, then the last transaction registers lstsrcreg and lstdstreg are not used, and the values in these registers are ignored. 17.8.1.1 burst transactions writing a 1 to the reqsrcreg[x]/reqdstreg[x] register is always interpreted as a burst transac- tion request, where x is the channel number. however, in order for a burst transaction request to start, software must write a 1 to the sglreqsrcreg[x]/sglreqdstreg[x] register. you can write a 1 to the sglreqsrcreg[ x ]/sglreqdstreg[ x ] and reqsrcreg[ x ]/reqdstreg[ x ] registers in any order, but both registers must be asserted in order to initiate a burst transaction. upon completion of the burst transaction, the hardware clears the sglreqsrcreg[ x ]/sglreqd- streg[ x ] and reqsrcreg[ x ]/reqdstreg[ x ] registers. 17.8.1.2 single transactions writing a 1 to the sg lreqsrcreg/sglreqdstreg initiates a single transaction. upon completion of the single transaction, both the sglreq srcreg/sglreqdstreg and reqsrcreg/reqdstreg bits are cleared by hardware. therefore, writ ing a 1 to the reqsrcreg/reqdstreg is ignored while a single transaction has been initiated, and the requested burst transaction is not serviced. again, writing a 1 to the reqsrcreg/reqdstre g register is always a burst transaction request. however, in order for a burst transaction request to start, the corresponding channel bit in the sglreqsrcreg/sglreqdstreg must be asserted. therefore, to ensure that a burst transaction is serviced, you must write a 1 to the reqsrcr eg/reqdstreg before writing a 1 to the sglreqsr- creg/sglreqdstreg register. software can poll the relevant channel bit in the sglreqsrcreg/ sglreqdstreg and reqsr- creg/reqdstreg registers. when both are 0, then either the requested burst or single transaction has completed. alternatively, the intsrctran or intdsttran interrupts can be enabled and unmasked in order to generate an interrupt when the requested source or destination trans- action has completed. note: the transaction-complete interrupts are trigger ed when both single and burst transactions are complete. the same transaction-complete interrupt is used for both single and burst transactions. 17.8.2 hardware handshaking there are 11 hardware handshaking interfaces between the dmaca and peripherals. refer to the module configuration chapter for the device-specific mapping of these interfaces.
174 32054f?avr32?09/09 at32ap7002 17.8.2.1 external dma request definition when an external slave peripheral requires the dmaca to perform dma transactions, it commu- nicates its request by asserting the external ndma reqx signal. this signal is resynchronized to ensure a proper functionality (see ?external dma request timing? on page 174 ). the external ndmareqx signal should be assert ed when the source threshold level is reached. after resynchronization, the rising edge of dma_req starts the transfer. the external ndmareqx signal must be de-ass erted after the last transfer and re-asserted again before a new transaction starts. for a source fifo, an active edge should be triggered on ndmareqx when the source fifo exceeds a watermark level. for a destination fifo, an active edge should be triggered on ndmareqx when the destination fifo drops below the watermark level. the source transaction length, ctlx.src_msize, and destination transaction length, ctlx.dest_msize, must be set according to watermark levels on the source/destination peripherals. figure 17-6. external dma request timing 17.9 dmaca transfer types a dma transfer may consist of single or multi-block transfers. on successive blocks of a multi- block transfer, the sarx/darx register in the dm aca is reprogrammed using either of the fol- lowing methods: ? block chaining using linked lists ? auto-reloading ? contiguous address between blocks on successive blocks of a multi-block transfer, the ctlx register in the dmaca is re-pro- grammed using either of the following methods: ? block chaining using linked lists ? auto-reloading when block chaining, using linked lists is the multi-block method of choice, and on successive blocks, the llpx register in the dmaca is re-programmed using the following method: ? block chaining using linked lists dma transfers dma transfers hclk ndmareqx dma_req dma_ack dma transfers dma transaction
175 32054f?avr32?09/09 at32ap7002 a block descriptor (lli) consists of following r egisters, sarx, darx, llpx, ctl. these regis- ters, along with the cfgx register, are used by the dmaca to set up and describe the block transfer. 17.9.1 multi-block transfers 17.9.1.1 block chaining using linked lists in this case, the dmaca re-programs the channel registers prior to the start of each block by fetching the block descriptor for that block from system memory. this is known as an lli update. dmaca block chaining is supported by using a linked list pointer register (llpx) that stores the address in memory of the next linked list item. each lli (block descriptor) contains the corre- sponding block descriptor (sarx, darx, llpx, ctlx). to set up block chaining, a sequence of linked lists must be programmed in memory. the sarx, darx, llpx and ctlx registers are fetched from system memory on an lli update. the updated contents of the ctlx register are written back to memory on block completion. fig- ure 17-7 on page 175 shows how to use chained linked lists in memory to define multi-block transfers using block chaining. the linked list multi-block transfers is initiated by programming llpx with llpx(0) (lli(0) base address) and ctlx with ctlx.llp_s_en and ctlx.llp_d_en. figure 17-7. multi-block transfer using linked lists system memory sarx darx llpx(1) ctlx[31..0] ctlx[63..32] sarx darx llpx(2) ctlx[31..0] ctlx[63..32] llpx(0) llpx(2) llpx(1) lli(0) lli(1)
176 32054f?avr32?09/09 at32ap7002 17.9.1.2 auto-reloading of channel registers during auto-reloading, the channel registers are reloaded with their initial values at the comple- tion of each block and the new values used for the new block. depending on the row number in table 17-1 on page 176 , some or all of the sarx, darx and ctlx channel registers are reloaded from their initial value at the start of a block transfer. 17.9.1.3 contiguous address between blocks in this case, the address between successive bloc ks is selected to be a continuation from the end of the previous block. enabling the source or destination address to be contiguous between table 17-1. programming of transfer types and channel register update method (dmaca state machine table) transfer type llp. loc = 0 llp_s_en ( ctlx) reload _sr ( cfgx) llp_d_en ( ctlx) reload_ ds ( cfgx) ctlx, llpx update method sarx update method darx update method write back 1) single block or last transfer of multi-block ye s 0 0 0 0 none, user reprograms none (single) none (single) no 2) auto reload multi-block transfer with contiguous sar ye s 0 0 0 1 ctlx,llpx are reloaded from initial values. contiguous auto- reload no 3) auto reload multi-block transfer with contiguous dar ye s 0 1 0 0 ctlx,llpx are reloaded from initial values. auto-reload con- tiguous no 4) auto reload multi-block transfer ye s 0 1 0 1 ctlx,llpx are reloaded from initial values. auto-reload auto- reload no 5) single block or last transfer of multi-block no 0 0 0 0 none, user reprograms none (single) none (single) ye s 6) linked list multi-block transfer with contiguous sar no 0 0 1 0 ctlx,llpx loaded from next linked list item contiguous linked list ye s 7) linked list multi-block transfer with auto-reload sar no 0 1 1 0 ctlx,llpx loaded from next linked list item auto-reload linked list ye s 8) linked list multi-block transfer with contiguous dar no 1 0 0 0 ctlx,llpx loaded from next linked list item linked list con- tiguous ye s 9) linked list multi-block transfer with auto-reload dar no 1 0 0 1 ctlx,llpx loaded from next linked list item linked list auto- reload ye s 10) linked list multi-block transfer no 1 0 1 0 ctlx,llpx loaded from next linked list item linked list linked list ye s
177 32054f?avr32?09/09 at32ap7002 blocks is a function of ctlx.llp_s_en, cfgx.reloa d_sr, ctlx.llp_d_en, and cfgx.reload_ds registers (see figure 17-1 on page 166 ). note: both sarx and darx updates cannot be se lected to be contiguous. if this functionality is required, the size of the block tr ansfer (ctlx.block_ts) must be increased. if this is at the max- imum value, use row 10 of table 17-1 on page 176 and setup the lli.sarx address of the block descriptor to be equal to the end sarx address of the previous block. similarly, setup the lli.darx address of the block descriptor to be equal to the end darx address of the previous block. 17.9.1.4 suspension of transfers between blocks at the end of every block transfer, an end of block interrupt is asserted if: ? interrupts are enabled, ctlx.int_en = 1 ? the channel block interrupt is unmasked, maskblock[n] = 0, where n is the channel number. note: the block complete interrupt is generated at the completion of the block transfer to the destination. for rows 6, 8, and 10 of table 17-1 on page 176 , the dma transfer does not stall between block transfers. for example, at the end of block n, the dmaca automatically proceeds to block n + 1. for rows 2, 3, 4, 7, and 9 of table 17-1 on page 176 (sarx and/or darx auto-reloaded between block transfers), the dma transfer automatically stalls after the end of block. interrupt is asserted if the end of block interrupt is enabled and unmasked. the dmaca does not proceed to the next block transfer until a write to the block interrupt clear register, clearblock[n], is performed by software. this clears the channel block complete interrupt. for rows 2, 3, 4, 7, and 9 of table 17-1 on page 176 (sarx and/or darx auto-reloaded between block transfers), the dma transfer does not stall if either: ? interrupts are disabled, ctlx.int_en = 0, or ? the channel block interrupt is masked, maskblock[n] = 1, where n is the channel number. channel suspension between blocks is used to ensu re that the end of block isr (interrupt ser- vice routine) of the next-to-last block is serviced before the start of the final block commences. this ensures that the isr has cleared the cfgx.reload_sr and/or cfgx.reload_ds bits before completion of the final block. the reload bits cfgx.reload_sr and/or cfgx.reload_ds should be cleared in the ?end of block isr? for the next-to-last block transfer. 17.9.2 ending multi-block transfers all multi-block transfers must end as shown in either row 1 or row 5 of table 17-1 on page 176 . at the end of every block transfer, the dmaca samples the row number, and if the dmaca is in row 1 or row 5 state, then the previous block transferred was the last block and the dma trans- fer is terminated. note: row 1 and row 5 are used for single block transfers or terminating multiblock transfers. ending in row 5 state enables status fetch for the last block. ending in row 1 state disables status fetch for the last block. for rows 2,3 and 4 of table 17-1 on page 176 , (llpx = 0 and cfgx.reload_sr and/or cfgx.reload_ds is set), multi-block dma transfers continue until both the cfgx.reload_sr and cfgx.reload_ds registers are cleared by software. they should be
178 32054f?avr32?09/09 at32ap7002 programmed to zero in the end of block interrupt service routine that services the next-to-last block transfer. this puts the dmaca into row 1 state. for rows 6, 8, and 10 (both cfgx.reload_sr and cfgx.reload_ds cleared) the user must setup the last block descriptor in memory such that both lli.ctlx.llp_s_en and lli.ctlx.llp_d_en are zero. if the lli.llpx register of the last block descriptor in memory is non-zero, then the dma transfer is terminated in row 5. if the lli.llpx register of the last block descriptor in memory is zero, then the dma transfer is terminated in row 1. for rows 7 and 9, the end-of-block interrupt serv ice routine that services the next-to-last block transfer should clear the cfgx.reload_sr and cfgx.reload_ds reload bits. the last block descriptor in memory should be set up so that both the lli.ctlx.llp_s_en and lli.ctlx.llp_d_en are zero. if the lli.llpx register of the last block descriptor in memory is non-zero, then the dma transfer is terminated in row 5. if the lli.llpx register of the last block descriptor in memory is zero, then the dma transfer is terminated in row 1. note: the only allowed transitions between the rows of table 17-1 on page 176 are from any row into row 1 or row 5. as already stated, a transition in to row 1 or row 5 is used to terminate the dma transfer. all other transitions between rows are not allowed. software must ensure that illegal tran- sitions between rows do not occur between blocks of a multi-block transfer. for example, if block n is in row 10 then the only allowed rows for block n + 1 are rows 10, 5 or 1. 17.10 programming a channel three registers, the llpx, the ctlx and cfgx, need to be programmed to set up whether single or multi-block transfers take place, and which type of multi-block transfer is used. the different transfer types are shown in table 17-1 on page 176 . the ?update method? column indicates where the values of sarx, darx, ctlx, and llpx are obtained for the next block transfer when multi-block dmaca transfers are enabled. note: in table 17-1 on page 176 , all other combinations of llpx.loc = 0, ctlx.llp_s_en, cfgx.reload_sr, ctlx.llp_d_en, and cfgx.r eload_ds are illegal, and causes indeter- minate or erroneous behavior. 17.10.1 programming examples 17.10.1.1 single-block transfer (row 1) row 5 in table 17-1 on page 176 is also a single block transfer. 1. read the channel enable register to choose a free (disabled) channel. 2. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all inter- rupts have been cleared. 3. program the following channel registers: a. write the starting source address in the sarx register for channel x. b. write the starting destination address in the darx register for channel x. c. program ctlx and cfgx according to row 1 as shown in table 17-1 on page 176 . program the llpx register with ?0?. d. write the control information for the dma transfer in the ctlx register for channel x. for example, in the register, you can program the following: ? i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the tt_fc of the ctlx register.
179 32054f?avr32?09/09 at32ap7002 ? ii. set up the transfer characteristics, such as: ? transfer width for the source in the src_tr_width field. ? transfer width for the destination in the dst_tr_width field. ? source master layer in the sms field where source resides. ? destination master layer in the dms field where destination resides. ? incrementing/decrementing or fixed address for source in sinc field. ? incrementing/decrementing or fixed address for destination in dinc field. e. write the channel configuration information into the cfgx register for channel x. ? i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests. writing a ?1? activates the software handshaking interface to handle source/destination requests. ? ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign a handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 4. after the dmaca selected channel has been programmed, enable the channel by writing a ?1? to the chenreg.ch_en bit. make sure that bit 0 of the dmacfgreg register is enabled. 5. source and destination request single and burst dma transactions to transfer the block of data (assuming non-memory peripherals). the dmaca acknowledges at the completion of every transaction (burst and single) in the block and carry out the block transfer. 6. once the transfer completes, hardware sets the interrupts and disables the channel. at this time you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is cleared by hardware, to detect when the transfer is complete. 17.10.1.2 multi-block transfer with linked list for source and linked list for destination (row 10) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the chain of linked list items (otherwise known as block descriptors) in memory. write the control information in the lli.ctlx register location of the block descriptor for each lli in memory (see figure 17-7 on page 175 ) for channel x. for example, in the register, you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and destina- tion) and flow control device by programming the tt_fc of the ctlx register. b. set up the transfer characteristics, such as: ? i. transfer width for the source in the src_tr_width field. ? ii. transfer width for the destination in the dst_tr_width field. ? iii. source master layer in th e sms field where source resides. ? iv. destination master layer in the dms field where destination resides. ? v. incrementing/decrementing or fixed address for source in sinc field. ? vi. incrementing/decrementing or fixed address for destination dinc field. 3. write the channel configuration information into the cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires program-
180 32054f?avr32?09/09 at32ap7002 ming the hs_sel_src/hs_sel_dst bits, re spectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the spe- cific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign the handshaking interface to the source and destination periph- eral. this requires programming the src_per and dest_per bits, respectively. 4. make sure that the lli.ctlx register locations of all lli entries in memory (except the last) are set as shown in row 10 of table 17-1 on page 176 . the lli.ctlx register of the last linked list item must be set as described in row 1 or row 5 of table 17-1 on page 176 . figure 17-9 on page 182 shows a linked list example with two list items. 5. make sure that the lli.llpx register locations of all lli entries in memory (except the last) are non-zero and point to the base address of the next linked list item. 6. make sure that the lli.sarx/lli.darx register locations of all lli entries in memory point to the start source/destination block address preceding that lli fetch. 7. make sure that the lli.ctlx.done field of the lli.ctlx register locations of all lli entries in memory are cleared. 8. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all inter- rupts have been cleared. 9. program the ctlx, cfgx registers according to row 10 as shown in table 17-1 on page 176 . 10. program the llpx register with llpx(0), the pointer to the first linked list item. 11. finally, enable the channel by writing a ?1? to the chenreg.ch_en bit. the transfer is performed. 12. the dmaca fetches the first lli from the location pointed to by llpx(0). note: the lli.sarx, lli. darx, lli.llpx and lli.ct lx registers are fetched. the dmaca automati- cally reprograms the sarx, darx, llpx and ctlx channel registers from the llpx(0). 13. source and destination request single and burst dma transactions to transfer the block of data (assuming non-memory peripheral). the dmaca acknowledges at the completion of every transaction (burst and single) in the block and carry out the block transfer. note: table 17-1 on page 176 14. the dmaca does not wait for the block interrupt to be cleared, but continues fetching the next lli from the memory location pointed to by current llpx register and automatically reprograms the sarx, darx, llpx and ctlx channel registers. the dma transfer con- tinues until the dmaca determines that the ctlx and llpx registers at the end of a block transfer match that described in row 1 or row 5 of table 17-1 on page 176 . the dmaca then knows that the previous block transferred was the last block in the dma transfer. the dma transfer might look like that shown in figure 17-8 on page 181 .
181 32054f?avr32?09/09 at32ap7002 figure 17-8. multi-block with linked list address for source and destination if the user needs to execute a dma transfer wh ere the source and destination address are con- tiguous but the amount of data to be transferred is greater than the maximum block size ctlx.block_ts, then this can be achieved usin g the type of multi-block transfer as shown in figure 17-9 on page 182 . sar(2) sar(1) sar(0) dar(2) dar(1) dar(0) block 2 block 1 block 0 block 0 block 1 block 2 address of source layer address of destination layer source blocks destination blocks
182 32054f?avr32?09/09 at32ap7002 figure 17-9. multi-block with linked address for source and destination blocks are contiguous the dma transfer flow is shown in figure 17-11 on page 185 . sar(2) sar(1) sar(0) dar(2) dar(1) dar(0) block 2 block 1 block 0 block 0 block 1 block 2 address of source layer address of destination layer source blocks destination blocks sar(3) block 2 dar(3) block 2
183 32054f?avr32?09/09 at32ap7002 figure 17-10. dma transfer flow for source and destination linked list address 17.10.1.3 multi-block transfer with source address auto-reloaded and destination address auto-reloaded (row 4) 1. read the channel enable register to choose an available (disabled) channel. 2. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all inter- rupts have been cleared. 3. program the following channel registers: channel enabled by software lli fetch hardware reprograms sarx, darx, ctlx, llpx dmac block transfer source/destination status fetch is dmac in row1 of dmac state machine table? channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no
184 32054f?avr32?09/09 at32ap7002 a. write the starting source address in the sarx register for channel x. b. write the starting destination address in the darx register for channel x. c. program ctlx and cfgx according to row 4 as shown in table 17-1 on page 176 . program the llpx register with ?0?. d. write the control information for the dma transfer in the ctlx register for channel x. for example, in the register, you can program the following: ? i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the tt_fc of the ctlx register. ? ii. set up the transfer characteristics, such as: ? transfer width for the source in the src_tr_width field. ? transfer width for the destination in the dst_tr_width field. ? source master layer in the sms field where source resides. ? destination master layer in the dms field where destination resides. ? incrementing/decrementing or fixed address for source in sinc field. ? incrementing/decrementing or fixed address for destination in dinc field. e. write the channel configuration information into the cfgx register for channel x. ensure that the reload bits, cfgx. reload_sr and cfgx.reload_ds are enabled. ? i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. ? ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 4. after the dmaca selected channel has been programmed, enable the channel by writing a ?1? to the chenreg.ch_en bit. make sure that bit 0 of the dmacfgreg register is enabled. 5. source and destination request single and burst dmaca transactions to transfer the block of data (assuming non-memory peripherals). the dmaca acknowledges on com- pletion of each burst/single transaction and carry out the block transfer. 6. when the block transfer has completed, the dmaca reloads the sarx, darx and ctlx registers. hardware sets the block comple te interrupt. the dmaca then samples the row number as shown in table 17-1 on page 176 . if the dmaca is in row 1, then the dma transfer has completed. hardware sets the transfer complete interrupt and disables the channel. so you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is disabled, to detect when the transfer is complete. if the dmaca is not in row 1, the next step is performed. 7. the dma transfer proceeds as follows: a. if interrupts are enabled (ctlx.int_en = 1) and the block complete interrupt is un- masked (maskblock[x] = 1?b1, where x is the channel number) hardware sets the block complete interrupt when the block transfer has completed. it then stalls until the block complete interrupt is cleared by software. if the next block is to be the last block in the dma transfer, then the block complete isr (interrupt service routine) should
185 32054f?avr32?09/09 at32ap7002 clear the reload bits in the cfgx.reload_sr and cfgx.reload_ds registers. this put the dmaca into row 1 as shown in table 17-1 on page 176 . if the next block is not the last block in the dma transfer, then the reload bits should remain enabled to keep the dmaca in row 4. b. if interrupts are disabled (ctlx.int_en = 0) or the block complete interrupt is masked (maskblock[x] = 1?b0, where x is the channel number), then hardware does not stall until it detects a write to the block complete interrupt clear register but starts the next block transfer immediately. in this case software must clear the reload bits in the cfgx.reload_sr and cfgx.reload_ds registers to put the dmaca into row 1 of table 17-1 on page 176 before the last block of the dma transfer has com- pleted. the transfer is similar to that shown in figure 17-11 on page 185 . the dma transfer flow is shown in figure 17-12 on page 186 . figure 17-11. multi-block dma transfer with source and destination address auto-reloaded address of source layer address of destination layer source blocks destination blocks blockn block2 block1 block0 sar dar
186 32054f?avr32?09/09 at32ap7002 figure 17-12. dma transfer flow for source and destination address auto-reloaded 17.10.1.4 multi-block transfer with source address auto-reloaded and linked list destination address (row7) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the chain of linked list items (otherwise known as block descriptors) in memory. write the control information in the lli.ctlx register location of the block descriptor for each lli in memory for channel x. for example, in the register you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and destina- tion) and flow control peripheral by programming the tt_fc of the ctlx register. b. set up the transfer characteristics, such as: ? i. transfer width for the source in the src_tr_width field. ? ii. transfer width for the destination in the dst_tr_width field. ? iii. source master layer in th e sms field where source resides. ? iv. destination master layer in the dms field where destination resides. ? v. incrementing/decrementing or fixed address for source in sinc field. ? vi. incrementing/decrementing or fixed address for destination dinc field. channel enabled by software block transfer reload sarx, darx, ctlx channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no yes stall until block complete interrupt cleared by software ctlx.int_en=1 && maskblock[x]=1? no is dmac in row1 of dmac state machine table?
187 32054f?avr32?09/09 at32ap7002 3. write the starting source address in the sarx register for channel x. note: the values in the lli.sarx register locations of each of the linked list items (llis) setup up in memory, although fetched during a lli fetch, are not used. 4. write the channel configuration information into the cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires program- ming the hs_sel_src/hs_sel_dst bits, re spectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the spe- cific channel. writing a ?1? activates the software handshaking interface source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 5. make sure that the lli.ctlx register locations of all llis in memory (except the last) are set as shown in row 7 of table 17-1 on page 176 while the lli.ctlx register of the last linked list item must be set as described in row 1 or row 5 of table 17-1 on page 176 . figure 17-7 on page 175 shows a linked list example with two list items. 6. make sure that the lli.llpx register locations of all llis in memory (except the last) are non-zero and point to the next linked list item. 7. make sure that the lli.darx register location of all llis in memory point to the start des- tination block address proceeding that lli fetch. 8. make sure that the lli.ctlx.done field of the lli.ctlx register locations of all llis in memory is cleared. 9. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all inter- rupts have been cleared. 10. program the ctlx, cfgx registers according to row 7 as shown in table 17-1 on page 176 . 11. program the llpx register with llpx(0), the pointer to the first linked list item. 12. finally, enable the channel by writing a ?1? to the chenreg.ch_en bit. the transfer is performed. make sure that bit 0 of the dmacfgreg register is enabled. 13. the dmaca fetches the first lli from the location pointed to by llpx(0). note: the lli.sarx, lli.darx, lli. llpx and lli.ct lx registers are fetched. the lli.sarx register although fetched is not used. 14. source and destination request single and burst dmaca transactions to transfer the block of data (assuming non-memory peripherals). dmaca acknowledges at the comple- tion of every transaction (burst and single) in the block and carry out the block transfer. 15. table 17-1 on page 176 the dmaca reloads the sarx regi ster from the initial value. hardware sets the block complete interrupt. the dmaca samples the row number as shown in table 17-1 on page 176 . if the dmaca is in row 1 or 5, then the dma transfer has completed. hardware sets the transfer complete interrupt and disables the channel. you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is cleared by hardware, to detect when the transfer is complete. if the dmaca is not in row 1 or 5 as shown in table 17-1 on page 176 the following steps are performed. 16. the dma transfer proceeds as follows: a. if interrupts are enabled (ctlx.int_en = 1) and the block complete interrupt is un- masked (maskblock[x] = 1?b1, where x is the channel number) hardware sets the block complete interrupt when the block transfer has completed. it then stalls until the
188 32054f?avr32?09/09 at32ap7002 block complete interrupt is cleared by software. if the next block is to be the last block in the dma transfer, then the block complete isr (interrupt service routine) should clear the cfgx.reload_sr source reload bit. this puts the dmaca into row1 as shown in table 17-1 on page 176 . if the next block is not the last block in the dma transfer, then the source reload bit should remain enabled to keep the dmaca in row 7 as shown in table 17-1 on page 176 . b. if interrupts are disabled (ctlx.int_en = 0) or the block complete interrupt is masked (maskblock[x] = 1?b0, where x is the channel number) then hardware does not stall until it detects a write to the block complete interrupt clear register but starts the next block transfer immediately. in th is case, software must clear the source reload bit, cfgx.reload_sr, to put the device into row 1 of table 17-1 on page 176 before the last block of the dma transfer has completed. 17. the dmaca fetches the next lli from memory location pointed to by the current llpx register, and automatically reprograms the darx, ctlx and llpx channel registers. note that the sarx is not re-programmed as the reloaded value is used for the next dma block transfer. if the next block is the last block of the dma transfer then the ctlx and llpx registers just fetched from the lli should match row 1 or row 5 of table 17-1 on page 176 . the dma transfer might look like that shown in figure 17-13 on page 188 . figure 17-13. multi-block dma transfer with source address auto-reloaded and linked list destination address the dma transfer flow is shown in figure 17-14 on page 189 . address of source layer address of destination layer source blocks destination blocks sar block0 block1 block2 blockn dar(n) dar(1) dar(0) dar(2)
189 32054f?avr32?09/09 at32ap7002 figure 17-14. dma transfer flow for source address auto-reloaded and linked list destina- tion address channel enabled by software lli fetch yes no no yes hardware reprograms darx, ctlx, llpx dmac block transfer source/destination status fetch reload sarx block complete interrupt generated here dmac transfer complete interrupt generated here channel disabled by hardware ctlx.int_en=1 && maskblock[x]=1 ? stall until block interrupt cleared by hardware is dmac in row1 or row5 of dmac state machine table?
190 32054f?avr32?09/09 at32ap7002 17.10.1.5 multi-block transfer with source address auto-reloaded and contiguous destination address (row 3) 1. read the channel enable register to choose a free (disabled) channel. 2. clear any pending interrupts on the channel from the previous dma transfer by writing a ?1? to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 3. program the following channel registers: a. write the starting source address in the sarx register for channel x. b. write the starting destination address in the darx register for channel x. c. program ctlx and cfgx according to row 3 as shown in table 17-1 on page 176 . program the llpx register with ?0?. d. write the control information for the dma transfer in the ctlx register for channel x. for example, in this register, you can program the following: ? i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the tt_fc of the ctlx register. ? ii. set up the transfer characteristics, such as: ? transfer width for the source in the src_tr_width field. ? transfer width for the destination in the dst_tr_width field. ? source master layer in the sms field where source resides. ? destination master layer in the dms field where destination resides. ? incrementing/decrementing or fixed address for source in sinc field. ? incrementing/decrementing or fixed address for destination in dinc field. e. write the channel configuration information into the cfgx register for channel x. ? i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. ? ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 4. after the dmaca channel has been programmed, enable the channel by writing a ?1? to the chenreg.ch_en bit. make sure that bit 0 of the dmacfgreg register is enabled. 5. source and destination request single and burst dmaca transactions to transfer the block of data (assuming non-memory peripherals). the dmaca acknowledges at the completion of every transaction (burst and single) in the block and carries out the block transfer. 6. when the block transfer has completed, the dmaca reloads the sarx register. the darx register remains unchanged. hardware sets the block complete interrupt. the dmaca then samples the row number as shown in table 17-1 on page 176 . if the dmaca is in row 1, then the dma transfer has completed. hardware sets the transfer complete interrupt and disables the channel. so you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chen-
191 32054f?avr32?09/09 at32ap7002 reg.ch_en) bit until it is cleared by hardware , to detect when the transfer is complete. if the dmaca is not in row 1, the next step is performed. 7. the dma transfer proceeds as follows: a. if interrupts are enabled (ctlx.int_en = 1) and the block complete interrupt is un- masked (maskblock[x] = 1?b1, where x is the channel number) hardware sets the block complete interrupt when the block transfer has completed. it then stalls until the block complete interrupt is cleared by software. if the next block is to be the last block in the dma transfer, then the block complete isr (interrupt service routine) should clear the source reload bit, cfgx.reload_ sr. this puts the dmaca into row1 as shown in table 17-1 on page 176 . if the next block is not the last block in the dma transfer then the source reload bit should remain enabled to keep the dmaca in row3 as shown in table 17-1 on page 176 . b. if interrupts are disabled (ctlx.int_en = 0) or the block complete interrupt is masked (maskblock[x] = 1?b0, where x is the channel number) then hardware does not stall until it detects a write to the block complete interrupt clear register but starts the next block transfer immediately. in this case software must clear the source reload bit, cfgx.reload_sr, to put the device into row 1 of table 17-1 on page 176 before the last block of the dma transfer has completed. the transfer is similar to that shown in figure 17-15 on page 191 . the dma transfer flow is shown in figure 17-16 on page 192 . figure 17-15. multi-block transfer with source address auto-reloaded and contiguous desti- nation address address of source layer address of destination layer source blocks destination blocks sar block0 block1 block2 dar(1) dar(0) dar(2)
192 32054f?avr32?09/09 at32ap7002 figure 17-16. dma transfer for source address auto-reloaded and contiguous destination address 17.10.1.6 multi-block dma transfer with linked list for source and contiguous destination address (row 8) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the linked list in memory. write the cont rol information in the lli. ctlx register location of the block descriptor for each lli in memory for channel x. for example, in the register, you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and destina- tion) and flow control device by programming the tt_fc of the ctlx register. b. set up the transfer characteristics, such as: ? i. transfer width for the source in the src_tr_width field. ? ii. transfer width for the destination in the dst_tr_width field. ? iii. source master layer in th e sms field where source resides. ? iv. destination master layer in the dms field where destination resides. ? v. incrementing/decrementing or fixed address for source in sinc field. channel enabled by software block transfer reload sarx, ctlx channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no no yes stall until block complete interrupt cleared by software ctlx.int_en=1 && maskblock[x]=1? is dmac in row1 of dmac state machine table?
193 32054f?avr32?09/09 at32ap7002 ? vi. incrementing/decrementing or fixed address for destination dinc field. 3. write the starting destination address in the darx register for channel x. note: the values in the lli.darx register location of each linked list item (lli) in memory, although fetched during an lli fetch, are not used. 4. write the channel configuration information into the cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires program- ming the hs_sel_src/hs_sel_dst bits, re spectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the spe- cific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripherals. this requires programming the src_per and dest_per bits, respectively. 5. make sure that all lli.ctlx register locations of the lli (except the last) are set as shown in row 8 of table 17-1 on page 176 , while the lli.ctlx register of the last linked list item must be set as described in row 1 or row 5 of table 17-1 on page 176 . figure 17-7 on page 175 shows a linked list example with two list items. 6. make sure that the lli.llpx register locations of all llis in memory (except the last) are non-zero and point to the next linked list item. 7. make sure that the lli.sarx register location of all llis in memory point to the start source block address proceeding that lli fetch. 8. make sure that the lli.ctlx.done field of the lli.ctlx register locations of all llis in memory is cleared. 9. clear any pending interrupts on the channel from the previous dma transfer by writing a ?1? to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 10. program the ctlx, cfgx registers according to row 8 as shown in table 17-1 on page 176 11. program the llpx register with llpx(0), the pointer to the first linked list item. 12. finally, enable the channel by writing a ?1? to the chenreg.ch_en bit. the transfer is performed. make sure that bit 0 of the dmacfgreg register is enabled. 13. the dmaca fetches the first lli from the location pointed to by llpx(0). note: the lli.sarx, lli.darx, lli.llpx and lli.ct lx registers are fetched . the lli.darx register location of the lli although fetched is not used. the darx register in the dmaca remains unchanged. 14. source and destination requests single and burst dmaca transactions to transfer the block of data (assuming non-memory peripherals). the dmaca acknowledges at the completion of every transaction (burst and single) in the block and carry out the block transfer. note: 15. the dmaca does not wait for the block interrupt to be cleared, but continues and fetches the next lli from the memory location pointed to by current llpx register and automati- cally reprograms the sarx, ctlx and llpx channel registers. the darx register is left unchanged. the dma transfer continues until the dmaca samples the ctlx and llpx registers at the end of a block transfer match that described in row 1 or row 5 of table 17-1 on page 176 . the dmaca then knows that the previous block transferred was the last block in the dma transfer.
194 32054f?avr32?09/09 at32ap7002 the dmaca transfer might look like that shown in figure 17-17 on page 194 note that the des- tination address is decrementing. figure 17-17. dma transfer with linked list source address and contiguous destination address the dma transfer flow is shown in figure 17-19 on page 195 . figure 17-18. sar(2) sar(1) sar(0) dar(2) dar(1) dar(0) block 2 block 1 block 0 block 0 block 1 block 2 address of source layer address of destination layer source blocks destination blocks
195 32054f?avr32?09/09 at32ap7002 figure 17-19. dma transfer flow for source address auto-reloaded and contiguous destination address 17.11 disabling a channel prio r to transfer completion under normal operation, software enables a channel by writing a ?1? to the channel enable reg- ister, chenreg.ch_en, and hardware disables a ch annel on transfer completion by clearing the chenreg.ch_en register bit. the recommended way for software to disable a channel without losing data is to use the ch_susp bit in conjunction with the fifo_empty bit in the channel configuration register (cfgx) register. channel enabled by software lli fetch hardware reprograms sarx, ctlx, llpx dmac block transfer source/destination status fetch is dmac in row 1 of table 4 ? channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no
196 32054f?avr32?09/09 at32ap7002 1. if software wishes to disable a channel prior to the dma transfer completion, then it can set the cfgx.ch_susp bit to tell the dmaca to halt all transfers from the source periph- eral. therefore, the channel fifo receives no new data. 2. software can now poll the cfgx.fifo_empty bit until it indicates that the channel fifo is empty. 3. the chenreg.ch_en bit can then be cleared by software once the channel fifo is empty. when ctlx.src_tr_width is less than ct lx.dst_tr_width and the cfgx.ch_susp bit is high, the cfgx.fifo_empty is asserted once the contents of the fifo do not permit a single word of ctlx.dst_tr_width to be formed. however, there may still be data in the channel fifo but not enough to form a single transfer of ctlx.dst_tr_width width. in this configura- tion, once the channel is disabled, the remaining data in the channel fifo are not transferred to the destination peripheral. it is permitted to remove the channel from the suspension state by writing a ?0? to the cfgx.ch_su sp register. the dma transfer completes in the normal manner. note: if a channel is disabled by software, an active single or burst transaction is not guaranteed to receive an acknowledgement. 17.11.1 abnormal transfer termination a dmaca dma transfer may be terminated abruptly by software by clearing the channel enable bit, chenreg.ch_en. this does not mean that th e channel is disabled immediately after the chenreg.ch_en bit is cleared over the hsb slave interface. consider this as a request to dis- able the channel. the chenreg.ch_en must be polled and then it must be confirmed that the channel is disabled by reading back 0. a case where the channel is not be disabled after a chan- nel disable request is where either the source or destination has received a split or retry response. the dmaca must keep re-attempting the transfer to the system haddr that origi- nally received the sp lit or retry response unt il an okay response is retu rned. to do otherwise is an system bus protocol violation. software may terminate all channels abruptly by clearing the global enable bit in the dmaca configuration register (dmacfgreg[0]). again, this does not mean that all channels are dis- abled immediately after the dmacfgreg[0] is cleared over the hsb slave interface. consider this as a request to disable all channels. the chenreg must be polled and then it must be con- firmed that all channels are disabled by reading back ?0?. note: if the channel enable bit is cleared while there is data in the channel fifo, this data is not sent to the destination peripheral and is not present when the channel is re-enabled. for read sensitive source peripherals such as a sour ce fifo this data is therefor e lost. when the source is not a read sensitive device (i.e., memory), disabling a channel without waiting for the channel fifo to empty may be acceptable as the data is available from the source peripheral upon request and is not lost. note: if a channel is disabled by software, an active single or burst transaction is not guaranteed to receive an acknowledgement.
197 32054f?avr32?09/09 at32ap7002 17.12 user interface table 17-2. dma controller memory map offset register register name access reset value 0x000 channel 0 source address register sar0 read/write 0x00000000 0x008 channel 0 destination addres s register dar0 read/write 0x00000000 0x010 channel 0 linked list pointer register llp0 read/write 0x00000000 0x018 channel 0 control register low ctl0l read/write 0x00304801 0x01c channel 0 control register high ctl0h read/write 0x00000002 0x040 channel 0 configuration register low cfg0l read/write 0x00000c00 0x044 channel 0 configuration register high cfg0h read/write 0x00000004 0x048 channel 0 source gather register sgr0 read/write 0x00000000 0x050 channel 0 destination scatter register dsr0 read/write 0x00000000 0x058 channel 1 source address register sar1 read/write 0x00000000 0x060 channel 1 destination addres s register dar1 read/write 0x00000000 0x068 channel 1 linked list pointer register llp1 read/write 0x00000000 0x070 channel 1 control register low ctl1l read/write 0x00304801 0x074 channel 1 control register high ctl1h read/write 0x00000002 0x098 channel 1 configuration register low cfg1l read/write 0x00000c20 0x09c channel 1 configuration register high cfg1h read/write 0x00000004 0x0a0 channel 1source gather register sgr1 read/write 0x00000000 0x0a8 channel 1 destination scatter register dsr1 read/write 0x00000000 0x0b0 channel 2 source address register sar2 read/write 0x00000000 0x0b8 channel 2 destination address register dar2 read/write 0x00000000 0x0c0 channel 2 linked list pointer register llp2 read/write 0x00000000 0x0c8 channel 2 control register low ctl2l read/write 0x00304801 0x0cc channel 2 control register high ctl2h read/write 0x00000002 0x0f0 channel 2 configuration register low cfg2l read/write 0x00000c40 0x0f4 channel 2 configuration register high cfg2h read/write 0x00000004 0x0f8 channel 2 source gather register sgr2 read/write 0x00000000 0x100 channel 2 destination scatter register dsr2 read/write 0x00000000 0x2c0 raw status for inttfr interrupt rawtfr read-only 0x00000000 0x2c8 raw status for intblock interrupt rawblock read-only 0x00000000 0x2d0 raw status for intsrctran interrupt rawsrctran read-only 0x00000000 0x2d8 raw status for intdsttran interrupt rawdsttran read-only 0x00000000 0x2e0 raw status for interr interrupt rawerr read-only 0x00000000 0x2e8 status for inttfr interrupt statustfr read-only 0x00000000 0x2f0 status for intblock interrupt statusblock read-only 0x00000000 0x2f8 status for intsrctran interrupt statussrctran read-only 0x00000000
198 32054f?avr32?09/09 at32ap7002 0x300 status for intdsttran interrupt statusdsttran read-only 0x00000000 0x308 status for interr interr upt statuserr read-only 0x00000000 0x310 mask for inttfr interrupt masktfr read/write 0x00000000 0x318 mask for intblock interrupt maskblock read/write 0x00000000 0x320 mask for intsrctran interrupt masksrctran read/write 0x00000000 0x328 mask for intdsttran interrupt maskdsttran read/write 0x00000000 0x330 mask for interr interrupt maskerr read/write 0x00000000 0x338 clear for inttfr interrupt cleartfr write-only 0x00000000 0x340 clear for intblock interrupt clearblock write-only 0x00000000 0x348 clear for intsrctran interrupt clearsrctran write-only 0x00000000 0x350 clear for intdsttran interrupt cleardsttran write-only 0x00000000 0x358 clear for interr interrupt clearerr write-only 0x00000000 0x360 status for each interrupt type statusint read-only 0x00000000 0x368 source software transaction request register reqsrcreg read/write 0x00000000 0x370 destination software transaction re quest register reqdstreg read/write 0x00000000 0x378 single source transaction request register sglreqsrcreg read/write 0x00000000 0x380 single destination transaction request register sglreqdstreg read/write 0x00000000 0x388 last source transaction request register lstsrcreg read/write 0x00000000 0x390 last destination transaction request register lstdstreg read/write 0x00000000 0x398 dma configuration register dmacfgreg read/write 0x00000000 0x3a0 dma channel enable register chenreg read/write 0x00000000 0x3f8 dma component id register low dmacompidregl read-only 0x44571110 0x3fc dma component id register high dmacompidregh read-only 0x3230362a table 17-2. dma controller memory map (continued) offset register register name access reset value
199 32054f?avr32?09/09 at32ap7002 17.12.1 channel x source address register name: sarx access type: read/write offset: 0x000 + [x * 0x58] reset value: 0x00000000 ? sadd: source address of dma transfer the starting system bus source address is programmed by software before the dma channel is enabled or by a lli update before the start of the dma transfer. as the dma transfer is in progress, this register is updated to reflect the source address of the current system bus transfer. updated after each source system bus transfer. the sinc field in the ctlx register determines whether the address incre- ments, decrements, or is left unchanged on every source system bus transfer throughout the block transfer. 31 30 29 28 27 26 25 24 sadd[31:24] 23 22 21 20 19 18 17 16 sadd[23:16] 15 14 13 12 11 10 9 8 sadd[15:8] 76543210 sadd[7:0]
200 32054f?avr32?09/09 at32ap7002 17.12.2 channel x destination address register name: darx access type: read/write offset: 0x008 + [x * 0x58] reset value: 0x00000000 ? dadd: destination address of dma transfer the starting system bus destination address is programmed by software before the dma channel is enabled or by a lli update before the start of the dma transfer. as the dma transfer is in progress, this register is updated to reflect the desti- nation address of the current system bus transfer. updated after each destination system bus transfer. the dinc fi eld in the ctlx register determines whether the address increments, decrements or is left unchanged on every destination system bus transfer throughout the block transfer. 31 30 29 28 27 26 25 24 dadd[31:24] 23 22 21 20 19 18 17 16 dadd[23:16] 15 14 13 12 11 10 9 8 dadd[15:8] 76543210 dadd[7:0]
201 32054f?avr32?09/09 at32ap7002 17.12.3 linked list pointer register for channel x name: llpx access type: read/write offset: 0x010 + [x * 0x58] reset value: 0x00000000 ? loc: address of the next lli starting address in memory of next lli if block chaining is enabled. the user need to program this register to point to the first linked list item (lli) in memory prior to enabling the channel if block chaining is enabled. the llp register has two functions: the logical result of the equation llp.loc != 0 is used to set up the type of dma transfer (single or multi-block). if llp.loc is set to 0x0, then transfers using linked lists are not enabled. this register must be programmed prior to enabling the channel in order to set up the transfer type. it (llp.loc != 0) contains the pointer to the next linked listed item for block chaining using linked lists. the llpx register is also used to point to the address where write back of the control and source/destination status infor- mation occurs afte r block completion. ? lms: list master select identifies the high speed bus interface for the device that stores the next linked list item: 31 30 29 28 27 26 25 24 loc[29:22] 23 22 21 20 19 18 17 16 loc[21:14] 15 14 13 12 11 10 9 8 loc[13:6] 76543210 loc[5:0] lms table 17-3. list master select lms hsb master 0 hsb master 1 1 hsb master 2 other reserved
202 32054f?avr32?09/09 at32ap7002 17.12.4 control register for channel x low name: ctlxl access type: read/write offset: 0x018 + [x * 0x58] reset value: 0x00304801 this register contains fields that control the dma transfer. t he ctlxl register is part of the block descriptor (linked list it em) when block chaining is enabled. it can be varied on a block-by-block basis within a dma transfer when block chaining is enabled. ? llp_src_en block chaining is only enabled on the source side if the llp_src_en field is high and llpx.loc is non-zero. ? llp_dst_en block chaining is only enabled on the destination side if the llp_dst_en field is high and llpx.loc is non-zero. ? sms: source master select identifies the master interface layer where the source device (peripheral or memory) is accessed from 31 30 29 28 27 26 25 24 llp_src_e n llp_dst_e n sms dms[1] 23 22 21 20 19 18 17 16 dms[0] tt_fc dst_gathe r_en src_gathe r_en src_msize [2] 15 14 13 12 11 10 9 8 src_msize[1:0] dest_msize sinc dinc[1] 76543210 dinc[0] src_tr_width dst_tr_width int_en table 17-4. source master select sms hsb master 0 hsb master 1 1 hsb master 2 other reserved
203 32054f?avr32?09/09 at32ap7002 ?dms: destination master select identifies the master interface layer where the destination device (peripheral or memory) resides ? tt_fc: transfer type and flow control the four following transfer types are supported: ? memory to memory, memory to peripheral, peripheral to memory and peripheral to peripheral. the dmaca is always the flow controller. ? dst_scatter_en: destination scatter enable 0 = scatter disabled 1 = scatter enabled scatter on the destination side is applicable only when the ctl x .dinc bit indicates an incrementing or decrementing address control. important note: this bit is only implemented for channel 1, not for channels 0 and 2. ? src_gather_en: source gather enable 0 = gather disabled 1 = gather enabled gather on the source side is applicable only when the ctl x .sinc bit indicates an incrementing or decrementing address control. important note: this bit is only implemented for channel 1, not for channels 0 and 2. ? src_msize: source burst transaction length number of data items, each of width ctlx.src_tr_width , to be read from the source every time a source burst transac- tion request is made from either the correspondi ng hardware or software handshaking interface. table 17-5. destination master select dms hsb master 0 hsb master 1 1 hsb master 2 other reserved tt_fc transfer type flow controller 000 memory to memory dmaca 001 memory to peripheral dmaca 010 peripheral to memory dmaca 011 peripheral to peripheral dmaca other reserved reserved src_msize size (items number) 01 14 28
204 32054f?avr32?09/09 at32ap7002 ? dst_msize: destination burst transaction length number of data items, each of width ctlx.dst_tr_width , to be written to the destination every time a destination burst transaction request is made from either the corres ponding hardware or software handshaking interface. ?sinc: source address increment indicates whether to increment or decrement the source addres s on every source system bus transfer. if your device is fetching data from a source peripheral fifo with a fixed address, then set this field to ?no change? ? dinc: destination address increment indicates whether to increment or decrement the destination address on every destination system bus transfer. if your device is writing data to a destination peripheral fifo with a fixed address, then set this field to ?no change? 316 432 other reserved dst_msize size (items number) 01 14 28 316 432 other reserved sinc source address increment 0 increment 1 decrement other no change dinc destination address increment 0 increment 1 decrement other no change src_msize size (items number)
205 32054f?avr32?09/09 at32ap7002 ? srt_tr_width: source transfer width ? dsc_tr_width: destin ation transfer width ? int_en: interrupt enable bit if set, then all five interrupt generating sources are enabled. src_tr_width/dst_tr_width size (bits) 08 116 232 other reserved
206 32054f?avr32?09/09 at32ap7002 17.12.5 control register for channel x high name: ctlxh access type: read/write offset: 0x01c + [x * 0x58] reset value: 0x00000002 ? done: done bit software can poll this bit to see when a block transfer is complete ? block_ts: block transfer size when the dmaca is flow controller, this fi eld is written by the user before the channel is enabled to indicate the block size. the number programmed into block_ts indicates the total number of single transactions to perform for every block transfer, unless the transfer is already in progress, in which case the value of block_ts indicates the number of single transactions that have been performed so far. the width of the single transaction is determined by ctlx.src_tr_width. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - done block_ts[11:8] 76543210 block_ts[7:0]
207 32054f?avr32?09/09 at32ap7002 17.12.6 configuration register for channel x low name: cfgxl access type: read/write offset: 0x040 + [x * 0x58] ? reset value: 0x00000c00 + [x * 0x20] ? reload_dst: automatic destination reload the darx register can be automatically reloaded from its initial value at the end of every block for multi-block transfers. a new block transfer is then initiated. ? reload_src: automatic source reload the sarx register can be automatically reloaded from its initial value at the end of every block for multi-block transfers. a new block transfer is then initiated. ? src_hs_pol: source handshaking interface polarity 0 = active high 1 = active low ? dst_hs_pol: destination handshaking interface polarity 0 = active high 1 = active low ? hs_sel_src: source software or hardware handshaking select this register selects which of the handshaking interfaces, hardware or software, is active for source requests on this channel. 0 = hardware handshaking interface. software-i nitiated transaction requests are ignored. 1 = software handshaking interface. hardware-initiated transaction requests are ignored. if the source peripheral is memory, then this bit is ignored. ? hs_sel_dst: destination software or hardware handshaking select this register selects which of the handshaking interfaces, hardware or software, is active for destination requests on this channel. 31 30 29 28 27 26 25 24 reload_d st reload_s rc ------ 23 22 21 20 19 18 17 16 - - - - src_hs_p ol dst_hs_po l -- 15 14 13 12 11 10 9 8 --hs_sel_sr c hs_sel_ds t fifo_empt y ch_susp 76543210 ch_prior - - - - -
208 32054f?avr32?09/09 at32ap7002 0 = hardware handshaking interface. software-i nitiated transaction requests are ignored. 1 = software handshaking interface. hardware initiated transaction requests are ignored. if the destination peripheral is memory, then this bit is ignored. ? fifo_empty indicates if there is data left in the channel's fifo. can be used in conjunction with cfgx .ch_susp to cleanly disable a channel. 1 = channel's fifo empty 0 = channel's fifo not empty ? ch_susp: channel suspend suspends all dma data transfers from the source until this bit is cleared. there is no guarantee that the current transaction will complete. can also be used in conjunction with cf gx.fifo_empty to cleanly disable a channel without losing any data. 0 = not suspended. 1 = suspend. suspend dma transfer from the source. ? ch_prior: channel priority a priority of 7 is the highest priority, and 0 is the lowest. this field must be programmed within the following range [0, x-1] . a programmed value outside this range causes erroneous behavior.
209 32054f?avr32?09/09 at32ap7002 17.12.7 configuration register for channel x high name: cfgxh access type: read/write offset: 0x044 + [x * 0x58] reset value: 0x00000004 ? dest_per: destination hardware handshaking interface assigns a hardware handshaking interface (0 - dm ah_num_hs_int-1) to th e destination of channel x if the cfgx.hs_sel_dst field is 0. otherwise, this field is ignored. the channel can then communicate with the destination peripheral connected to that interface via the assigned hardware handshaking interface. for correct dma operation, only one peripheral (source or destination) should be assigned to the same handshaking interface. ? src_per: source hardware handshaking interface assigns a hardware handshaking interface (0 - dmah_num_hs_int-1) to the source of channel x if the cfgx.hs_sel_src field is 0. otherwise, this field is ignored. the channel can then communicate with the source periph- eral connected to that interface via th e assigned hardware handshaking interface. for correct dmaca operation, only one peripheral (source or destination) should be assigned to the same handshaking interface. ?protctl: protection control bits used to drive the system bus hprot[3:1] bus. the system bus specification recommends that the default value of hprot indicates a non-cached, nonbuffered, privileged data access. the reset value is used to indicate such an access. hprot[0] is tied high as all transfers are data accesses as there are no opcode fetches. there is a one-to-one mapping of these register bits to the hprot[3:1] master interface signals. ?fifo_mode: r/w 0x0 fifo mode select determines how much space or data needs to be available in the fifo before a burst transaction request is serviced. 0 = space/data available for single system bu s transfer of the specified transfer width. 1 = space/data available is greater than or equal to half the fifo depth for destination transfe rs and less than half the fifo depth for source transfers. the exceptions are at the end of a burst transaction request or at the end of a block transfer. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - dest_per src_per[3:1] 76543210 src_per[0] - - protctl fifo_mode fcmode
210 32054f?avr32?09/09 at32ap7002 ?fcmode: flow control mode determines when source transaction requests are serviced when the destination peripheral is the flow controller. 0 = source transaction requests are serviced when they occur. data pre-fetching is enabled. 1 = source transaction requests are not serviced until a destinatio n transaction request occurs. in this mode the amount of dat a transferred from the source is limited such that it is guaranteed to be transferred to the destination prior to block terminati on by the destination. data pre-fetching is disabled.
211 32054f?avr32?09/09 at32ap7002 17.12.8 source gather register for channel x name: sgrx access type: read/write offset: 0x048 + [x * 0x58] reset value: 0x00000000 ? sgc: source gather count specifies the number of contiguous source transfers of ctl x .src_tr_width between successive gather intervals. this is defined as a gather boundary. ?sgi: source gather interval specifies the source address increment/decrement in multiples of ctl x .src_tr_width on a gather boundary when gather mode is enabled for the source transfer. important note: this register is only implemented for channel 1, not for channels 0 and 2. 31 30 29 28 27 26 25 24 sgc[11:4] 23 22 21 20 19 18 17 16 sgc[3:0] sgi[19:16] 15 14 13 12 11 10 9 8 sgi[15:8] 76543210 sgi[7:0]
212 32054f?avr32?09/09 at32ap7002 17.12.9 destination scatter register for channel x name: dsrx access type: read/write offset: 0x050 + [x * 0x58] reset value: 0x00000000 ? dsc: destination scatter count specifies the number of contiguous destination transfers of ctl x .dst_tr_width between successive scatter boundaries. ?dsi: destination scatter interval specifies the destination address increment/decrement in multiples of ctl x .dst_tr_width on a scatter boundary when scatter mode is enabled for the destination transfer. important note: this register is only implemented for channel 1, not for channels 0 and 2. 31 30 29 28 27 26 25 24 dsc[11:4] 23 22 21 20 19 18 17 16 dsc[3:0] dsi[19:16] 15 14 13 12 11 10 9 8 dsi[15:8] 76543210 dsi[7:0]
213 32054f?avr32?09/09 at32ap7002 17.12.10 interrupt registers the following sections describe the registers pertaining to interrupts, their status, and how to clear them. for each channel, there are five types of interrupt sources: ? inttfr: dma transfer complete interrupt this interrupt is generated on dma transfer completion to the destination peripheral. ? intblock: block transfer complete interrupt this interrupt is generated on dma block transfer completion to the destination peripheral. ? intsrctran: source transaction complete interrupt this interrupt is generated after completion of the last sy stem bus transfer of the requested single/burst transaction from the handshaking interface on the source side. if the source for a channel is memory, then that channel never generates a intsrctran interrupt and hence the correspond- ing bit in this field is not set. ? intdsttran: destination transaction complete interrupt this interrupt is generated after completion of the last sy stem bus transfer of the requested single/burst transaction from the handshaking interface on the destination side. if the destination for a channel is memory, then that channel never generates the intdsttran interrupt and hence the corre- sponding bit in this field is not set. ? interr: error interrupt this interrupt is generated when an error response is received from an hsb slave on the hresp bus during a dma transfer. in addition, the dma transfer is cancelled and the channel is disabled.
214 32054f?avr32?09/09 at32ap7002 17.12.11 interrupt raw status registers name: rawtfr, rawblock, rawsrc tran, rawdsttran, rawerr access type: read-only offset: 0x2c0, 0x2c8, 0x2d0, 0x2d8, 0x2e0 reset value: 0x00000000 ? raw[2:0]raw interrupt for each channel interrupt events are stored in these raw interrupt status registers before masking: rawtfr, rawblock, rawsrctran, rawdsttran, rawerr. each raw interrupt status register has a bit allocated per channel, for example, rawtfr[2] is chan- nel 2?s raw transfer complete interrupt. each bit in these regi sters is cleared by writing a 1 to the corresponding location in the cleartfr, clear block, clearsrctran, cleards ttran, clearerr registers. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - raw2 raw1 raw0
215 32054f?avr32?09/09 at32ap7002 17.12.12 interrupt status registers name: statustfr, statusblock, statussrctran, statusdsttran, statuserr access type: read-only offset: 0x2e8, 0x2f0, 0x2f8, 0x300, 0x308 reset value: 0x00000000 ? status[2:0] all interrupt events from all channels are stored in these interr upt status registers after masking: statustfr, statusblock, statussrctran, statusdsttran, statuserr. each interrupt status register has a bit allocated per channel, for example, sta- tustfr[2] is channel 2?s status transfer complete interrupt.the contents of these registers are used to generate the interrupt signals leaving the dmaca. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - status2 status1 status0
216 32054f?avr32?09/09 at32ap7002 17.12.13 interrupt mask registers name: masktfr, maskblock, masksrctran, maskdsttran, maskerr access type: read/write offset: 0x310, 0x318, 0x320, 0x328, 0x330 reset value: 0x00000000 the contents of the raw status registers are masked with the contents of the mask register s: masktfr, maskblock, mask- srctran, maskdsttran, maskerr. each interrupt mask register has a bit allocated per channel, for example, masktfr[2] is the mask bit for channel 2?s transfer complete interrupt. a channel?s int_mask bit is only writt en if the corresponding mask write enable bit in the in t_mask_we field is asserted on the same system bus write transfer. this allows software to set a mask bit without performing a read-modified write operation. for example, writing hex 01x1 to the masktfr register writes a 1 into masktfr[0], while masktfr[7:1] remains unchanged. writing hex 00 xx leaves masktfr[7:0] unchanged. writing a 1 to any bit in these registers unmasks the corresponding interrupt, thus allowing the dmaca to set the appropri- ate bit in the status registers. ? int_m_we[10:8]: interrupt mask write enable 0 = write disabled 1 = write enabled ? int_mask[2:0]: interrupt mask 0= masked 1 = unmasked 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - int_m_we2 int_m_we1 int_m_we0 76543210 - - - - - int_mask2 int_mask1 int_mask0
217 32054f?avr32?09/09 at32ap7002 17.12.14 interrupt clear registers name: cleartfr, clearblo ck, clearsrctran, cle ardsttran, clearerr access type: write-only offset: 0x338, 0x340, 0x348, 0x350, 0x358 reset value: 0x00000000 ? clear[2:0]: interrupt clear 0 = no effect 1 = clear interrupt each bit in the raw status and status registers is cleared on the same cycle by writing a 1 to the corresponding location in the clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. each interrupt clear register has a bit allo- cated per channel, for example, cleartfr[2] is the clear bit fo r channel 2?s transfer complete interrupt. writing a 0 has no effect. these registers are not readable. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - clear2 clear1 clear0
218 32054f?avr32?09/09 at32ap7002 17.12.15 combined interrupt status registers name: statusint access type: read-only offset: 0x360 reset value: 0x00000000 the contents of each of the five status registers (statustfr , statusblock, statussrctran, statusdsttran, statuserr) is or?ed to produce a single bit per interrupt type in the combined status register (statusint). ?err or of the contents of statuserr register. ?dstt or of the contents of statusdsttran register. ? srct or of the contents of statussrctran register. ?block or of the contents of statusblock register. ?tfr or of the contents of statustfr register. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - err dstt srct block tfr
219 32054f?avr32?09/09 at32ap7002 17.12.16 source software transaction request register name: reqsrcreg access type: read/write offset: 0x368 reset value: 0x00000000 a bit is assigned for each channel in this register. reqsrcreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel src_req bit is written only if the corresponding ch annel write enable bit in the req_we field is asserted on the same system bus write transfer. for example, writing 0x101 writes a 1 into reqsrcreg[0] , while reqsrcreg[4:1] remains unchanged. writing hex 0x0 yy leaves reqsrcreg[4:0] unchanged. this allows software to set a bit in the reqsrcreg register without performing a read- modified write ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled ? src_req[2:0]: source request 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - req_we2 req_we1 req_we0 76543210 - - - - - src_req2 src_req1 src_req0
220 32054f?avr32?09/09 at32ap7002 17.12.17 destination software transaction request register name: reqdstreg access type: read/write offset: 0x370 reset value: 0x00000000 a bit is assigned for each channel in this register. reqdstreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel dst_req bit is written only if the corresponding channel write enable bit in the req_we field is asserted on the same system bus write transfer. ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled ? dst_req[2:0]: destination request 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - req_we2 req_we1 req_we0 76543210 - - - - - dst_req2 dst_req1 dst_req0
221 32054f?avr32?09/09 at32ap7002 17.12.18 single source transaction request register name: sglreqsrcreg access type: read/write offset: 0x378 reset value: 0x00000000 a bit is assigned for each channel in this register. sglreqsrcreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel s_sg_req bit is written only if the corresponding channel write enable bit in th e req_we field is asserted on the same system bus write transfer. ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled ? s_sg_req[2:0]: source single request 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - req_we2 req_we1 req_we0 76543210 - - - - - s_sg_req2 s_sg_req1 s_sg_req0
222 32054f?avr32?09/09 at32ap7002 17.12.19 single destination transaction request register name: sglreqdstreg access type: read/write offset: 0x380 reset value: 0x0000000 a bit is assigned for each channel in this register. sglreqdstreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel d_sg_req bit is written only if the corresponding channel write enable bit in the req_we field is asserted on the same system bus write transfer. ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled ? d_sg_req[2:0]: destin ation single request 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - - req_we2 req_we1 req_we0 76543210 - - - - - d_sg_req2 d_sg_req1 d_sg_req0
223 32054f?avr32?09/09 at32ap7002 17.12.20 last source transaction request register name: lstsrcreg access type: read/write offset: 0x388 reset value: 0x0000000 a bit is assigned for each channel in this register. lstsrcreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel lstsrc bit is written only if the corresponding c hannel write enable bit in the lstsrc_we field is asserted on the same system bus write transfer. ? lstsrc_we[10:8]: source last transaction request write enable 0 = write disabled 1 = write enabled ? lstsrc[2:0]: source last transaction request 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----lstsrc_w e2 lstsrc_w e1 lstsrc_w e0 76543210 - - - - - lstsrc2 lstsrc1 lstsrc0
224 32054f?avr32?09/09 at32ap7002 17.12.21 last destination transaction request register name: lstdstreg access type: read/write offset: 0x390 reset value: 0x00000000 a bit is assigned for each channel in this register. lstdstreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel lstdst bit is written only if the corresponding channel write enable bit in the lstdst_we field is asserted on the same system bus write transfer. ? lstdst_we[10:8]: destination last transaction request write enable 0 = write disabled 1 = write enabled ? lstdst[2:0]: destination last transaction request 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----lstdst_we 2 lstdst_we 1 lstdst_we 0 76543210 - - - - - lstdst2 lstdst1 lstdst0
225 32054f?avr32?09/09 at32ap7002 17.12.22 dma configuration register name: dmacfgreg access type: read/write offset: 0x398 reset value: 0x00000000 ? dma_en: dma controller enable 0 = dmaca disabled 1 = dmaca enabled. this register is used to enable the dmaca, which must be done before any channel activity can begin. if the global channel enable bit is clear ed while any channel is still active, then dm acfgreg.dma_en still returns ?1? to indi- cate that there are channels still active until hardware has terminated all activity on all channels, at which point the dmacfgreg.dma_en bit returns ?0?. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------dma_en
226 32054f?avr32?09/09 at32ap7002 17.12.23 dma channel enable register name: chenreg access type: read/write offset: 0x3a0 reset value: 0x00000000 ? ch_en_we[10:8]: channel enable write enable the channel enable bit, ch_en, is only written if the corresponding channel writ e enable bit, ch_en_we, is asserted on the same system bus write transfer. for example, writing 0x101 writes a 1 into chenreg[0], while chenreg[7:1] remains unchanged. ? ch_en[2:0] 0 = disable the channel 1 = enable the channel enables/disables the channel. setting this bit enables a channel, clearing this bit disables the channel. the chenreg.ch_en bit is automatically cleared by hardware to disable the channel after the last system bus transfer of the dma transfer to the destination has completed.software ca n therefore poll this bit to determine when a dma transfer has completed. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----ch_en_we 2 ch_en_we 1 ch_en_we 0 76543210 - - - - - ch_en2 ch_en1 ch_en0
227 32054f?avr32?09/09 at32ap7002 17.12.24 dmaca component id register low name: dmacompidregl access type: read-only offset: 0x3f8 reset value: 0x44571110 ? dma_comp_type designware component type number = 0x44571110. this assigned unique hex value is constant and is derived from the two ascii letters ?dw? followed by a 32-bit unsigned number 31 30 29 28 27 26 25 24 dma_comp_type[31:24] 23 22 21 20 19 18 17 16 dma_comp_type[23:16] 15 14 13 12 11 10 9 8 dma_comp_type[15:8] 76543210 dma_comp_type[7:0]
228 32054f?avr32?09/09 at32ap7002 17.12.25 dmaca component id register high name: dmacompidregh access type: read-only offset: 0x3fc reset value: 0x3230362a ? dma_comp_version: version of the component 31 30 29 28 27 26 25 24 dma_comp_version[31:24] 23 22 21 20 19 18 17 16 dma_comp_version[23:16] 15 14 13 12 11 10 9 8 dma_comp_version[15:8] 76543210 dma_comp_version[7:0]
229 32054f?avr32?09/09 at32ap7002 18. peripheral dma controller (pdc) rev: 1.0.0.1 18.1 features ? generates transfers to/from peripherals such as usart, ssc and spi ? supports up to 20 chan nels (product dependent) ? one master clock cycle needed for a transfer from memory to peripheral ? two master clock cycles needed for a transfer from peripheral to memory 18.2 description the peripheral dma controller (pdc) transfers data between on-chip serial peripherals such as the uart, usart, ssc, spi, and the on- and off-chip memories. using the peripheral dma controller avoids processor intervention and removes the processor interrupt-handling over- head. this significantly reduces the number of clock cycles required for a data transfer and, as a result, improves the performance of the microcontroller and makes it more power efficient. the pdc channels are implemented in pairs, each pair being dedicated to a particular periph- eral. one channel in the pair is dedicated to the receiving channel and one to the transmitting channel of each uart, usart, ssc and spi. the user interface of a pdc channel is integrated in the memory space of each peripheral. it contains: ? a 32-bit memory pointer register ? a 16-bit transfer count register ? a 32-bit register for next memory pointer ? a 16-bit register for next transfer count the peripheral triggers pdc transfers usin g transmit and receive signals. when the pro- grammed data is transferred, an end of trans fer interrupt is generated by the corresponding peripheral.
230 32054f?avr32?09/09 at32ap7002 18.3 block diagram figure 18-1. block diagram control pdc channel 0 pdc channel 1 thr rhr control status & control peripheral peripheral dma controller memory controller
231 32054f?avr32?09/09 at32ap7002 18.4 product dependencies 18.4.1 power management the pdc clock is generated by the power manager. the pdc also depends on the hsb-hsb bridge clock. before using the pdc, the programmer must ensure that the pdc clock and hsb- hsb bridge clock are enabled in the power manager. to prevent bus errors the pdc operation must be terminated before entering sleep mode 18.4.2 interrupt the pdc has an interrupt line for each channel connected to the interrupt controller via the cor- responding peripheral. handling the pdc interrupt requires programming the interrupt controller before configuring the pdc. 18.4.3 peripherals before using each pdc channel the corresponding peripheral has to be configured correctly. 18.5 functional description 18.5.1 configuration the pdc channels user interface enables the user to configure and control the data transfers for each channel. the user interface of a pdc channel is integrated into the user interface of the peripheral (offset 0x100), which it is related to. per peripheral, it contains four 32-bit pointer registers (rpr, rnpr, tpr, and tnpr) and four 16-bit counter re gisters (rcr, rncr, tcr, and tncr). the size of the buffer (number of transfers) is configured in an internal 16-bit transfer counter register, and it is possible, at any moment, to read the number of transfers left for each channel. the memory base address is configured in a 32-bit memory pointer by defining the location of the first address to access in the memory. it is possible, at any moment, to read the location in memory of the next transfer and the number of remaining transfers. the pdc has dedicated sta- tus registers which indicate if the transfer is enabl ed or disabled for each channel. the status for each channel is located in the peripheral status register. transfers can be enabled and/or dis- abled by setting txten/txtdis and rxten/rxtd is in pdc transfer co ntrol register. these control bits enable reading the pointer and counter registers safely without any risk of their changing between both reads. the pdc sends status flags to the peripheral visible in its status-register (endrx, endtx, rxbuff, and txbufe). endrx flag is set when the periph_rcr register reaches zero. rxbuff flag is set when both pe riph_rcr and periph_rncr reach zero. endtx flag is set when the per iph_tcr register reaches zero. txbufe flag is set when both pe riph_tcr and periph_tncr reach zero. these status flags are described in the peripheral status register.
232 32054f?avr32?09/09 at32ap7002 18.5.2 memory pointers each peripheral is connected to the pdc by a receiver data channel and a transmitter data channel. each channel has an internal 32-bit memory pointer. each memory pointer points to a location anywhere in the memory space (on-chip memory or external bus interface memory). depending on the type of transfer (byte, half-word or word), the memory pointer is incremented by 1, 2 or 4, respectively for peripheral transfe rs. the size of the transfer is setup up in the peripheral?s control register and automatically sensed by the pdc. the size is always rounded up to wither byte, half-word or word. if a memory pointer is reprogrammed while the pdc is in operation, the transfer address is changed, and the pdc performs transfers using the new address. 18.5.3 transfer counters there is one internal 16-bit transfer counter for each channel used to count the size of the block already transferred by its associated channel. these counters are decremented after each data transfer. when the counter reaches zero, the transfer is complete and the pdc stops transfer- ring data. if the next counter register is equal to zero, the pdc disables the trigger while activating the related peripheral end flag. if the counter is reprogrammed while the pdc is operating, the number of transfers is updated and the pdc counts transfers from the new value. programming the next counter/pointer register s chains the buffers. the counters are decre- mented after each data transfer as stated above, but when the transfer counter reaches zero, the values of the next counter/pointer are loaded into the counter/pointer registers in order to re-enable the triggers. for each channel, two status bits indicate the end of the current buffer (endrx, entx) and the end of both current and next buffer (rxbuff, txbufe). these bits are directly mapped to the peripheral status register and can trigger an interrupt request to the interrupt controller. the peripheral end flag is automatically cleared when one of the counter-registers (counter or next counter regi ster) is written. note: when the next counter register is loaded into the counter register, it is set to zero. 18.5.4 data transfers the peripheral triggers pdc transfers using transmit (txrdy) and receive (rxrdy) signals. when the peripheral receives an external characte r, it sends a receive ready signal to the pdc which then requests access to the system bus. when access is granted, the pdc starts a read of the peripheral receive holding register (rhr) and then triggers a write in the memory. after each transfer, the relevant pdc memory pointer is incremented and the number of trans- fers left is decremented. when the memory bl ock size is reached, a signal is sent to the peripheral and the transfer stops. the same procedure is followed, in reverse, for transmit transfers.
233 32054f?avr32?09/09 at32ap7002 18.5.5 priority of pdc transfer requests the peripheral dma controller handles transfer requests from the channel according to priori- ties fixed for each product.these prioriti es are defined in the product datasheet. if simultaneous requests of the same type (receiver or transmitter) occur on identical peripher- als, the priority is determined by the numbering of the peripherals. if transfer requests are not simultaneous, they are treated in the order they occurred. requests from the receivers are handled first and then followed by transmitter requests.
234 32054f?avr32?09/09 at32ap7002 18.6 peripheral dma controll er (pdc) user interface note: 1. periph: ten registers are mapped in the peripheral memory space at the same offset. these can be defined by the user according to the function and the per ipheral desired (usart, ssc, spi, etc). table 18-1. register mapping offset register register name read/write reset 0x100 receive pointer register periph (1) _rpr read/write 0x0 0x104 receive counter register periph_rcr read/write 0x0 0x108 transmit pointer register periph_tpr read/write 0x0 0x10c transmit counter register periph_tcr read/write 0x0 0x110 receive next pointer register periph_rnpr read/write 0x0 0x114 receive next counter register periph_rncr read/write 0x0 0x118 transmit next pointer register periph_tnpr read/write 0x0 0x11c transmit next counter register periph_tncr read/write 0x0 0x120 pdc transfer control register periph_ptcr write-only - 0x124 pdc transfer status r egister periph_ptsr read-only 0x0
235 32054f?avr32?09/09 at32ap7002 18.6.1 pdc receive pointer register register name: periph _ rpr access type: read/write ? rxptr: receive pointer address address of the next receive transfer. 31 30 29 28 27 26 25 24 rxptr 23 22 21 20 19 18 17 16 rxptr 15 14 13 12 11 10 9 8 rxptr 76543210 rxptr
236 32054f?avr32?09/09 at32ap7002 18.6.2 pdc receive counter register register name: periph _ rcr access type: read/write ? rxctr: receive counter value number of receive transfers to be performed. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 rxctr 76543210 rxctr
237 32054f?avr32?09/09 at32ap7002 18.6.3 pdc transmit pointer register register name: periph _ tpr access type: read/write ? txptr: transmit pointer address address of the transmit buffer. 31 30 29 28 27 26 25 24 txptr 23 22 21 20 19 18 17 16 txptr 15 14 13 12 11 10 9 8 txptr 76543210 txptr
238 32054f?avr32?09/09 at32ap7002 18.6.4 pdc transmit counter register register name: periph _ tcr access type: read/write ? txctr: transmit counter value txctr is the size of the transmit transfer to be performed. at zero, the peripheral data transfer is stopped. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 txctr 76543210 txctr
239 32054f?avr32?09/09 at32ap7002 18.6.5 pdc receive next pointer register register name: periph _ rnpr access type: read/write ? rxnptr: receive next pointer address rxnptr is the address of the next buffer to fill with received data when th e current buffer is full. 31 30 29 28 27 26 25 24 rxnptr 23 22 21 20 19 18 17 16 rxnptr 15 14 13 12 11 10 9 8 rxnptr 76543210 rxnptr
240 32054f?avr32?09/09 at32ap7002 18.6.6 pdc receive next counter register register name: periph _ rncr access type: read/write ? rxncr: receive next counter value rxncr is the size of the next buffer to receive. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 rxncr 76543210 rxncr
241 32054f?avr32?09/09 at32ap7002 18.6.7 pdc transmit next pointer register register name: periph _ tnpr access type: read/write ? txnptr: transmit next pointer address txnptr is the address of the next buffer to transmit when the current buffer is empty. 31 30 29 28 27 26 25 24 txnptr 23 22 21 20 19 18 17 16 txnptr 15 14 13 12 11 10 9 8 txnptr 76543210 txnptr
242 32054f?avr32?09/09 at32ap7002 18.6.8 pdc transmit next counter register register name: periph _ tncr access type: read/write ? txncr: transmit next counter value txncr is the size of the next buffer to transmit. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 txncr 76543210 txncr
243 32054f?avr32?09/09 at32ap7002 18.6.9 pdc transfer control register register name: periph_ptcr access type: write - only ? rxten: receiver transfer enable 0 = no effect. 1 = enables the receiver pdc transfer requests if rxtdis is not set. ? rxtdis: receiver transfer disable 0 = no effect. 1 = disables the receiver pdc transfer requests. ? txten: transmitter transfer enable 0 = no effect. 1 = enables the transmitter pdc transfer requests. ? txtdis: transmitter transfer disable 0 = no effect. 1 = disables the transmitter pdc transfer requests 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txtdistxten 76543210 ??????rxtdisrxten
244 32054f?avr32?09/09 at32ap7002 18.6.10 pdc transfer status register register name: periph _ ptsr access type: read-only ? rxten: receiver transfer enable 0 = receiver pdc transfer requests are disabled. 1 = receiver pdc transfer requests are enabled. ? txten: transmitter transfer enable 0 = transmitter pdc transfer requests are disabled. 1 = transmitter pdc transfer requests are enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????txten 76543210 ???????rxten
245 32054f?avr32?09/09 at32ap7002 19. parallel input/outp ut controller (pio) rev: 2.0.2.3 19.1 features ? up to 32 programmable i/o lines ? fully programmable through set/clear registers ? multiplexing of two peripheral functions per i/o line ? for each i/o line (whether assigned to a peripheral or used as general purpose i/o) ? input change interrupt ? glitch filter ? programmable pull up on each i/o line ? pin data status register, supplies visibility of the le vel on the pin at any time ? synchronous output, provides set and clear of several i/o lines in a single write 19.2 description the parallel input/output controller (pio) manages up to 32 fully programmable input/output lines. each i/o line may be dedicated as a general-purpose i/o or be assigned to a function of an embedded peripheral. this assures effective optimization of the pins of a product. each i/o line is associated with a bit number in all of the 32-bit registers of the 32-bit wide user interface. each i/o line of the pio controller features: ?an input change interrupt enabling level change detection on any i/o line. ?a glitch filter providing rejection of pulses lower than one-half of clock cycle. ?control of the the pull-up of the i/o line. ?input visibility an d output control. the pio controller also features a synchronous output providing up to 32 bits of data output in a single write operation.
246 32054f?avr32?09/09 at32ap7002 19.3 block diagram figure 19-1. block diagram figure 19-2. application block diagram embedded peripheral embedded peripheral pio interrupt pio controller up to 32 pins power manager up to 32 peripheral ios up to 32 peripheral ios clk_pio peripheral bus interrupt controller data, enable pin 31 pin 1 pin 0 data, enable on-chip peripherals pio controller on-chip peripheral drivers control & command driver keyboard driver keyboard driver general purpose i/os external devices
247 32054f?avr32?09/09 at32ap7002 19.4 product dependencies 19.4.1 pin multiplexing each pin is configurable, according to product definition as either a general-purpose i/o line only, or as an i/o line multiplexed with one or two peripheral i/os. as the multiplexing is hard- ware-defined and thus product-dependent, the hardware designer and programmer must carefully determine the configuration of the pio controllers required by their application. when an i/o line is general-purpose only, i.e. not multiplexed with any peripheral i/o, programming of the pio controller regarding the assignment to a peripheral has no effect and only the pio con- troller can control how the pin is driven by the product. 19.4.2 external interrupt lines the external interrupt request signals are most generally multiplexed through the pio control- lers. however, it is not necessary to assign t he i/o line to the interrupt function as the pio controller has no effect on inputs and the external interrupt lines are used only as inputs. 19.4.3 power management the pio clock (clk_pio) is generated by the power manager. before accessing the pio, the programmer must ensure that clk_pio is enabled in the power manager. note that clk_pio must be enabled when using the input change interrupt. in the pio description, clk_pio is the cloc k of the peripheral bus to which the pio is connected. 19.4.4 interrupt generation the pio interrupt line is connected to the interr upt controller. using th e pio interrupt requires the interrupt controller to be programmed first.
248 32054f?avr32?09/09 at32ap7002 19.5 functional description the pio controller features up to 32 fully-programmable i/o lines. most of the control logic asso- ciated to each i/o is represented in figure 19-3 . in this description each signal shown represents but one of up to 32 possible indexes. figure 19-3. i/o line control logic 1 0 1 0 1 0 1 0 glitch filter peripheral b input peripheral a input 1 0 ifdr[0] ifsr[0] ifer[0] edge detector pdsr[0] isr[0] idr[0] imr[0] ier[0] pio interrupt (up to 32 possible inputs) isr[31] idr[31] imr[31] ier[31] pad pudr[0] pusr[0] puer[0] codr[0] odsr[0] sodr[0] pdr[0] psr[0] per[0] 1 0 1 0 bsr[0] absr[0] asr[0] peripheral b output enable peripheral a output enable peripheral b output peripheral a output odr[0] osr[0] oer[0] mddr[0] mdsr[0] mder[0] codr[0] odsr[0] sodr[0] mddr[0] mdsr[0] mder[0]
249 32054f?avr32?09/09 at32ap7002 19.5.1 pull-up resistor control each i/o line is designed with an embedded pull-up resistor. the pull-up resistor can be enabled or disabled by writing respectively puer (p ull-up enable register) and pudr (pull-up disable resistor). writing in these registers results in setting or clearing the corresponding bit in pusr (pull-up status register). reading a 1 in pusr means the pull-up is disabled and reading a 0 means the pull-up is enabled. control of the pull-up resistor is possible regardless of the configuration of the i/o line. after reset, all of the pull-ups are enabled, i.e. pusr resets at the value 0x0. 19.5.2 i/o line or peripheral function selection when a pin is multiplexed with one or two periph eral functions, the selection is controlled with the registers per (pio enable register) and pdr (pio disable register). the register psr (pio status register) is the result of the set and clear registers and indicates whether the pin is controlled by the corresponding peripheral or by the pio controller. a value of 0 indicates that the pin is controlled by the corresponding on-chip peripheral selected in the absr (ab select status register). a value of 1 indicates the pin is controlled by the pio controller. if a pin is used as a general purpose i/o line (not multiplexed with an on-chip peripheral), per and pdr have no effect and psr returns 1 for the corresponding bit. after reset, most generally, the i/o lines are controlled by the pio controller, i.e. psr resets at 1. however, in some events, it is important that pio lines are controlled by the peripheral (as in the case of memory chip select lines that must be driven inactive after reset or for address lines that must be driven low for booting out of an external memory). thus, the reset value of psr is defined at the product level, depending on the multiplexing of the device. 19.5.3 peripheral a or b selection the pio controller provides multiplexing of up to two peripheral functions on a single pin. the selection is performed by writ ing asr (a select register) and bsr (select b register). absr (ab select status register) indicates which peri pheral line is currently selected. for each pin, the corresponding bit at level 0 means peripheral a is selected whereas the corresponding bit at level 1 indicates that pe ripheral b is selected. note that multiplexing of peripheral lines a and b only affects the output line. the peripheral input lines are always connected to the pin input. after reset, absr is 0, thus indicating that all the pio lines are configured on peripheral a. how- ever, peripheral a generally does not drive the pin as the pio controller resets in i/o line mode. writing in asr and bsr manages absr regardless of the configuration of the pin. however, assignment of a pin to a peripheral function requires a write in the corresponding peripheral selection register (asr or bsr) in addition to a write in pdr. 19.5.4 output control when the i/0 line is assigned to a peripheral function, i.e. the corresponding bit in psr is at 0, the drive of the i/o line is controlled by the peripheral. peripheral a or b, depending on the value in absr, determines whether the pin is driven or not. when the i/o line is controlled by the pio controller, the pin can be configured to be driven. this is done by writing oer (output enable register) and odr (output disable register). the results of these write operations are detected in osr (output status register). when a bit in this
250 32054f?avr32?09/09 at32ap7002 register is at 0, the corresponding i/o line is used as an input only. when the bit is at 1, the cor- responding i/o line is driven by the pio controller. the level driven on an i/o line can be determined by writing in sodr (set output data register) and codr (clear output data register). these write operations respectively set and clear odsr (output data status register), which represents the data driven on the i/o lines. writing in oer and odr manages osr whether the pin is configured to be controlled by the pio con- troller or assigned to a peripheral function. this enables configuration of the i/o line prior to setting it to be managed by the pio controller. similarly, writing in sodr and co dr effects odsr. this is importan t as it defines the first level driven on the i/o line. 19.5.5 multi-drive capability the pio is able to configure each pin as open drain to support external drivers on the same pin. this is done by writing mder (multi-drive en able register) and mddr (multi-drive disable register). the result of these write operations are detected in mdsr (multui-drive status regis- ter). the multi-drive mode is only available when the pio is controlling the pin, i.e. psr is set. when using multi-drive the pio will tri-state the pin when odsr is set and drive the pin low when odsr is cleared. writing to oer or odr will have no effect. 19.5.6 synchronous data output controlling all paralle l busses using several pios requires two successive write operations in the sodr and codr registers. this may lead to unexpected transient values. the pio controller offers a direct control of pio outputs by single write access to odsr (output data status regis- ter). only bits unmasked by owsr (output write status register) are written. the mask bits in the owsr are set by writing to ower (output write enable register) and cleared by writing to owdr (output write disable register). after reset, the synchronous data output is disabled on all the i/o lines as owsr resets at 0x0. 19.5.7 output line timings figure 19-4 shows how the outputs are driven either by writing sodr or codr, or by directly writing odsr. this last case is valid only if the corresponding bit in owsr is set. figure 19-4 also shows when the feedback in pdsr is available. figure 19-4. output line timings 2 cycles peripheral bus access 2 cycles peripheral bus access clk_pio write sodr write odsr at 1 odsr pdsr write codr write odsr at 0
251 32054f?avr32?09/09 at32ap7002 19.5.8 inputs the level on each i/o line can be read through pdsr (pin data status register). this register indicates the level of the i/o lines regardless of their configuration, whether uniquely as an input or driven by the pio controller or driven by a peripheral. reading the i/o line levels requires the clock of the pio controller to be enabled, otherwise pdsr reads the levels present on the i/o line at the time the clock was disabled. 19.5.9 input glitch filtering optional input glitch filters are independently programmable on each i/o line. when the glitch fil- ter is enabled, a glitch with a duration of less than 1/2 clk_pio cycle is automatically rejected, while a pulse with a duration of 1 clk_pio cycle or more is accepted. for pulse durations between 1/2 clk_pio cycle and 1 clk_pio cycle the pulse may or may not be taken into account, depending on the precise timing of its occurrence. thus for a pulse to be visible it must exceed 1 clk_pio cycle, whereas for a glitch to be reliably filtered out, its duration must not exceed 1/2 clk_pio cycle. the filter introduces one clk_pio cycle latency if the pin level change occurs before a rising edge. however, this latency does not appear if the pin level change occurs before a falling edge. this is illustrated in figure 19-5 . the glitch filters are controlled by the register set; ifer (input filter enable register), ifdr (input filter disable register) and ifsr (input filter status register). writing ifer and ifdr respectively sets and clears bits in ifsr. this last register enables the glitch filter on the i/o lines. when the glitch filter is enabled, it does not modify the behavior of the inputs on the peripherals. it acts only on the value read in pdsr and on the input change interrupt detection. the glitch fil- ters require that the pio controller clock is enabled. figure 19-5. input glitch filter timing 19.5.10 input change interrupt the pio controller can be programmed to generate an interrupt when it detects an input change on an i/o line. the input change interrupt is controlled by writing ier (interrupt enable register) and idr (interrupt disable register), which respectively enable and disable the input change interrupt by setting and clearing the corresponding bit in imr (interrupt mask register). as input change detection is possible only by comparing two successive samplings of the input of the i/o line, the pio controller clock must be enabled. the input change interrupt is available, regard- less of the configuration of the i/o line, i.e. configured as an input only, controlled by the pio controller or assigned to a peripheral function. clk_pio pin level pdsr if ifsr = 0 pdsr if ifsr = 1 1 cycle 1 cycle 1 cycle up to 1.5 cycles 2 cycles up to 2.5 cycles up to 2 cycles 1 cycle 1 cycle
252 32054f?avr32?09/09 at32ap7002 when an input change is detected on an i/o line, the corresponding bit in isr (interrupt status register) is set. if the corresponding bit in imr is set, the pio controller interrupt line is asserted. the interrupt signals of the thirty-two channels are ored-wired together to generate a single interrupt signal to the interrupt controller. when the software reads isr, all the interrupts are automatically cleared. th is signifies that all the interrupts that are pending when isr is read must be handled. figure 19-6. input change interrupt timings 19.6 i/o lines programming example the programing example as shown in table 19-1 below is used to define the following configuration. ?4-bit output port on i/o lines 0 to 3, (should be written in a single write operation) ?four output signals on i/o lines 4 to 7 (to drive leds for example) ?four input signals on i/o lines 8 to 11 (to read push-button states for example), with pull-up resistors, glitch filters and input change interrupts ?four input signals on i/o line 12 to 15 to read an external device status (polled, thus no input change interrupt), no pull-up resistor, no glitch filter ?i/o lines 16 to 19 assigned to peripheral a functions with pull-up resistor ?i/o lines 20 to 23 assigned to peripheral b functions, no pull-up resistor ?i/o line 24 to 27 assigned to peripheral a with input change interrupt and pull-up resistor clk_pio pin level read isr peripheral bus access isr peripheral bus access
253 32054f?avr32?09/09 at32ap7002 table 19-1. programming example register value to be written per 0x0000 ffff pdr 0x0fff 0000 oer 0x0000 00ff odr 0x0fff ff00 ifer 0x0000 0f00 ifdr 0x0fff f0ff sodr 0x0000 0000 codr 0x0fff ffff ier 0x0f00 0f00 idr 0x00ff f0ff pudr 0x00f0 00f0 puer 0x0f0f ff0f asr 0x0f0f 0000 bsr 0x00f0 0000 ower 0x0000 000f owdr 0x0fff fff0
254 32054f?avr32?09/09 at32ap7002 19.7 user interface each i/o line controlled by the pio controller is associated with a bit in each of the pio control- ler user interface registers. each register is 32 bits wide. if a parallel i/o line is not defined, writing to the corresponding bits has no effect. undefined bits read zero. if the i/o line is not mul- tiplexed with any peripheral, the i/o line is controlled by the pio controller and psr returns 1 systematically. table 19-2. register mapping offset register name access reset value 0x0000 pio enable register per write-only ? 0x0004 pio disable register pdr write-only ? 0x0008 pio status register psr read-only (1) 0x000c reserved 0x0010 output enable register oer write-only ? 0x0014 output disable register odr write-only ? 0x0018 output status regi ster osr read-only 0x0000 0000 0x001c reserved 0x0020 glitch input filter en able register ifer write-only ? 0x0024 glitch input filter dis able register ifdr write-only ? 0x0028 glitch input filter status register ifsr read-only 0x0000 0000 0x002c reserved 0x0030 set output data register sodr write-only ? 0x0034 clear output data register codr write-only ? 0x0038 output data status register odsr read-only or read/write (2) 0x0000 0000 0x003c pin data status register (3) pdsr read-only 0x0040 interrupt enable register ier write-only ? 0x0044 interrupt disable register idr write-only ? 0x0048 interrupt mask register imr read-only 0x0000 0000 0x004c interrupt status register (4) isr read-only 0x0000 0000 0x0050 multi-driver enable register mder write-only 0x0054 multi-driver disable register mddr write-only 0x0058 multi-driver status register mdsr read-only 0x005c reserved 0x0060 pull-up disable register pudr write-only ? 0x0064 pull-up enable register puer write-only ? 0x0068 pad pull-up status r egister pusr read-only 0x0000 0000
255 32054f?avr32?09/09 at32ap7002 notes: 1. reset value of psr depends on the product implementation. 2. odsr is read-only or read/write depending on owsr i/o lines. 3. reset value of pdsr depends on the level of the i/o lines. 4. isr is reset at 0x0. however, the first read of the register may read a different value as input changes may have occurred. 5. only this set of registers clears the status by writing 1 in the first register and sets the st atus by writing 1 in the secon d register. 0x006c reserved 0x0070 peripheral a select register (5) asr write-only ? 0x0074 peripheral b select register (5) bsr write-only ? 0x0078 ab status register (5) absr read-only 0x0000 0000 0x007c to 0x009c reserved 0x00a0 output write enable ower write-only ? 0x00a4 output write disable owdr write-only ? 0x00a8 output write status re gister owsr read-only 0x0000 0000 0x00ac- 0x00fc reserved table 19-2. register mapping (continued) offset register name access reset value
256 32054f?avr32?09/09 at32ap7002 19.7.1 pio controller pio enable register name: per access type: write-only ? p0-p31: pio enable 0 = no effect. 1 = enables the pio to control the corresponding pin (disables peripheral control of the pin). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
257 32054f?avr32?09/09 at32ap7002 19.7.2 pio controller pio disable register name: pdr access type: write-only ? p0-p31: pio disable 0 = no effect. 1 = disables the pio from controllin g the corresponding pin (enables peripheral contro l of the pin). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
258 32054f?avr32?09/09 at32ap7002 19.7.3 pio controller pio status register name: psr access type: read-only ? p0-p31: pio status 0 = pio is inactive on the corresponding i/o line (peripheral is active). 1 = pio is active on the corresponding i/o line (peripheral is inactive). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
259 32054f?avr32?09/09 at32ap7002 19.7.4 pio controller output enable register name: oer access type: write-only ? p0-p31: output enable 0 = no effect. 1 = enables the output on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
260 32054f?avr32?09/09 at32ap7002 19.7.5 pio controller output disable register name: odr access type: write-only ? p0-p31: output disable 0 = no effect. 1 = disables the output on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
261 32054f?avr32?09/09 at32ap7002 19.7.6 pio controller output status register name: osr access type: read-only ? p0-p31: output status 0 = the i/o line is a pure input. 1 = the i/o line is enabled in output. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
262 32054f?avr32?09/09 at32ap7002 19.7.7 pio controller glitch input filter enable register name: ifer access type: write-only ? p0-p31: input filter enable 0 = no effect. 1 = enables the input glitch filter on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
263 32054f?avr32?09/09 at32ap7002 19.7.8 pio controller glitch input filter disable register name: ifdr access type: write-only ? p0-p31: input filter disable 0 = no effect. 1 = disables the input glitch filter on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
264 32054f?avr32?09/09 at32ap7002 19.7.9 pio controller glitch input filter status register name: ifsr access type: read-only ? p0-p31: input filer status 0 = the input glitch filter is disabled on the i/o line. 1 = the input glitch filter is enabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
265 32054f?avr32?09/09 at32ap7002 19.7.10 pio controller set output data register name: sodr access type: write-only ? p0-p31: set output data 0 = no effect. 1 = sets the data to be driven on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
266 32054f?avr32?09/09 at32ap7002 19.7.11 pio controller clear output data register name: codr access type: write-only ? p0-p31: set output data 0 = no effect. 1 = clears the data to be driven on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
267 32054f?avr32?09/09 at32ap7002 19.7.12 pio controller output data status register name: odsr access type: read-only or read/write ? p0-p31: output data status 0 = the data to be driven on the i/o line is 0. 1 = the data to be driven on the i/o line is 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
268 32054f?avr32?09/09 at32ap7002 19.7.13 pio controller pin data status register name: pdsr access type: read-only ? p0-p31: output data status 0 = the i/o line is at level 0. 1 = the i/o line is at level 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
269 32054f?avr32?09/09 at32ap7002 19.7.14 pio controller interrupt enable register name: ier access type: write-only ? p0-p31: input change interrupt enable 0 = no effect. 1 = enables the input change interrupt on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
270 32054f?avr32?09/09 at32ap7002 19.7.15 pio controller interrupt disable register name: idr access type: write-only ? p0-p31: input change interrupt disable 0 = no effect. 1 = disables the input change interrupt on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
271 32054f?avr32?09/09 at32ap7002 19.7.16 pio controller interrupt mask register name: imr access type: read-only ? p0-p31: input change interrupt mask 0 = input change interrupt is disabled on the i/o line. 1 = input change interrupt is enabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
272 32054f?avr32?09/09 at32ap7002 19.7.17 pio controller interrupt status register name: isr access type: read-only ? p0-p31: input change interrupt status 0 = no input change has been detected on the i/o line since isr was last read or since reset. 1 = at least one input change has been detected on the i/o line since isr was last read or since reset. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
273 32054f?avr32?09/09 at32ap7002 19.7.18 pio controller multi-driver enable register name: mder access type: write-only this register is used to enable pio output drivers to be conf igured as open drain to support external drivers on the same pin. ?p0-p31: 0 = no effect. 1 = enables multi-drive option on the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
274 32054f?avr32?09/09 at32ap7002 19.7.19 pio controller multi-driver disable register name: mddr access type: write-only this register is used to diasble the open drain configuration of the output buffer. ?p0-p31: 0 = no effect. 1 = disables multi-drive option on the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
275 32054f?avr32?09/09 at32ap7002 19.7.20 pio controller multi-driver status register name: mdsr access type: read-only this register indicates which pins are configured with open drain drivers. ?p0-p31: 0 = pio is not configured as an open drain. 1 = pio is configured as an open drain. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
276 32054f?avr32?09/09 at32ap7002 19.7.21 pio pull up disable register name: pudr access type: write-only ? p0-p31: pull up disable. 0 = no effect. 1 = disables the pull up resistor on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
277 32054f?avr32?09/09 at32ap7002 19.7.22 pio pull up enable register name: puer access type: write-only ? p0-p31: pull up enable. 0 = no effect. 1 = enables the pull up resistor on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
278 32054f?avr32?09/09 at32ap7002 19.7.23 pio pull up status register name: pusr access type: read-only ? p0-p31: pull up status. 0 = pull up resistor is enabled on the i/o line. 1 = pull up resistor is disabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
279 32054f?avr32?09/09 at32ap7002 19.7.24 pio peripheral a select register name: asr access type: write-only ? p0-p31: peripheral a select. 0 = no effect. 1 = assigns the i/o line to the peripheral a function. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
280 32054f?avr32?09/09 at32ap7002 19.7.25 pio peripheral b select register name: bsr access type: write-only ? p0-p31: peripheral b select. 0 = no effect. 1 = assigns the i/o line to the peripheral b function. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
281 32054f?avr32?09/09 at32ap7002 19.7.26 pio peripheral a b status register name: absr access type: read-only ? p0-p31: peripheral a b status. 0 = the i/o line is assigned to the peripheral a. 1 = the i/o line is assigned to the peripheral b. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
282 32054f?avr32?09/09 at32ap7002 19.7.27 pio output write enable register name: ower access type: write-only ? p0-p31: output write enable. 0 = no effect. 1 = enables writing od sr for the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
283 32054f?avr32?09/09 at32ap7002 19.7.28 pio output write disable register name: owdr access type: write-only ? p0-p31: output write disable. 0 = no effect. 1 = disables writing odsr for the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
284 32054f?avr32?09/09 at32ap7002 19.7.29 pio output write status register name: owsr access type: read-only ? p0-p31: output write status. 0 = writing odsr does not affect the i/o line. 1 = writing odsr affects the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
285 32054f?avr32?09/09 at32ap7002 20. serial peripheral interface (spi) rev: 1.7.1.3 20.1 features ? supports communication with serial external devices ? four chip selects with external decoder support allow communication with up to 15 peripherals ? serial memories, such as dataflash and 3-wire eeproms ? serial peripherals, such as adcs, dacs, lcd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 8- to 16-bit programmable data length per chip select ? programmable phase and polarity per chip select ? programmable transfer delays between consec utive transfers and be tween clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? connection to pdc channel capabi lities optimizes data transfers ? one channel for the receiver, on e channel for the transmitter ? next buffer support 20.2 description the serial peripheral interface (spi) circuit is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi syste m acts as the ?master?' which controls the data flow, while the other devices act as ?slaves'' whic h have data shifted into and out by the master. different cpus can take turn being masters (multiple master protocol opposite to single master protocol where one cpu is always the master while all of the others are always slaves) and one master may simultaneously shift da ta into multiple slaves. howeve r, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when the master asse rts its nss signal. if multiple slave devices exist, the master generates a separate slav e select signal for each slave (npcs). the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input(s) of the slave(s). ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. there may be no more than one slave transmitting data during any particular transfer. ? serial clock (spck): this control line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates; the spck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows slaves to be turned on and off by hardware.
286 32054f?avr32?09/09 at32ap7002 20.3 block diagram figure 20-1. block diagram spi interface interrupt control pio pdc power manager mck spi interrupt spck miso mosi npcs0/nss npcs1 npcs2 div npcs3 ral bus mck 32 (1)
287 32054f?avr32?09/09 at32ap7002 20.4 application block diagram figure 20-2. application block diagram: single master/multiple slave implementation spi master spck miso mosi npcs0 npcs1 npcs2 spck miso mosi nss slave 0 spck miso mosi nss slave 1 spck miso mosi nss slave 2 nc npcs3
288 32054f?avr32?09/09 at32ap7002 20.5 signal description table 20-1. signal description pin name pin description type master slave miso master in slave out input output mosi master out slave in output input spck serial clock output input npcs1-npcs3 peripheral chip selects output unused npcs0/nss peripheral chip select/slave select output input
289 32054f?avr32?09/09 at32ap7002 20.6 product dependencies 20.6.1 i/o lines the pins used for interfacing the compliant ex ternal devices may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the spi pins to their peripheral functions. to use the local loopback function the spi pins must be controlled by the spi. 20.6.2 power management the spi clock is generated by the power manager. before using the spi, the programmer must ensure that the spi clock is enabled in the power manager. in the spi description, master clock (mck) is the clock of the per ipheral bus to which the spi is connected. 20.6.3 interrupt the spi interface has an interrupt line connected to the interrupt controller. handling the spi interrupt requires programming the interrupt controller before configuring the spi.
290 32054f?avr32?09/09 at32ap7002 20.7 functional description 20.7.1 modes of operation the spi operates in master mode or in slave mode. operation in master mode is programmed by writing at 1 the mstr bit in the mode register. the pins npcs0 to npcs3 are all configured as outputs, the spck pin is driven, the miso line is wired on the receiver input and the mosi line driven as an output by the transmitter. if the mstr bit is written at 0, the spi operates in slave mode. the miso line is driven by the transmitter output, the mosi line is wired on the re ceiver input, the spck pin is driven by the transmitter to synchronize the receiver. the npcs0 pin becomes an input, and is used as a slave select signal (nss). the pins npcs1 to npcs3 are not driven and can be used for other purposes. the data transfers are identically programmable for both modes of operations. the baud rate generator is activated only in master mode. 20.7.2 data transfer four combinations of polarity and phase are available for data transfers. the clock polarity is programmed with the cpol bit in the chip select register. the clock phase is programmed with the ncpha bit. these two parameters determine th e edges of the clock signal on which data is driven and sampled. each of the two parameters has two possible states, resulting in four possi- ble combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to communicate. if multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a dif- ferent slave. table 20-2 shows the four modes and corresponding parameter settings. figure 20-3 and figure 20-4 show examples of data transfers. table 20-2. spi bus protocol mode spi mode cpol ncpha 001 100 211 310
291 32054f?avr32?09/09 at32ap7002 figure 20-3. spi transfer format (ncpha = 1, 8 bits per transfer) figure 20-4. spi transfer format (ncpha = 0, 8 bits per transfer) 6 * spck (cpol = 0) spck (cpol = 1) mosi (from master) miso (from slave) nss (to slave) spck cycle (for reference) msb msb lsb lsb 6 6 5 5 4 4 3 3 2 2 1 1 * not defined, but normally msb of previous character received. 1 2345 78 6 * spck (cpol = 0) spck (cpol = 1) 1 2345 7 mosi (from master) miso (from slave) nss (to slave) spck cycle (for reference) 8 msb msb lsb lsb 6 6 5 5 4 4 3 3 1 1 * not defined but normally lsb of previous character transmitted. 2 2 6
292 32054f?avr32?09/09 at32ap7002 20.7.3 master mode operations when configured in master mode, the spi uses the internal programmable baud rate generator as clock source. it fully controls the data transfers to and from the slave(s) connected to the spi bus. the spi drives the chip select line to the slave and the serial clock signal (spck). the spi features two holding registers, the transmit data register and the receive data regis- ter, and a single shift register. the holding registers maintain the data flow at a constant rate. after enabling the spi, a data transfer begins when the processor writes to the tdr (transmit data register). the written data is immediately transferred in the shift register and transfer on the spi bus starts. while the data in the shift register is shifted on the mosi line, the miso line is sampled and shifted in the shift register. transmission cannot occur without reception. before writing the tdr, the pcs field must be set in order to select a slave. if new data is written in tdr during the transfer, it stays in it until the current transfer is com- pleted. then, the received data is transferred from the shift register to rdr, the data in tdr is loaded in the shift register and a new transfer starts. the transfer of a data written in tdr in the shift register is indicated by the tdre bit (transmit data register empty) in the status register (s r). when new data is written in tdr, this bit is cleared. the tdre bit is used to trigger the tran smit pdc channel. the end of transfer is indicated by the txempty fl ag in the sr register. if a transfer delay (dly- bct) is greater than 0 for the last transfer, txempty is set after the completion of said delay. the master clock (mck) can be switched off at this time. the transfer of received data from the shift re gister in rdr is indicated by the rdrf bit (receive data register full) in the status r egister (sr). when the received data is read, the rdrf bit is cleared. if the rdr (receive data register) has not been read before new data is received, the overrun error bit (ovres) in sr is set. when this bi t is set the spi will continue to update rdr when data is received, overwriting the previously receiv ed data. the user has to read the status regis- ter to clear the ovres bit. figure 20-5 on page 293 shows a block diagram of the spi when operating in master mode. fig- ure 20-6 on page 294 shows a flow chart describing how transfers are handled.
293 32054f?avr32?09/09 at32ap7002 20.7.3.1 master mode block diagram figure 20-5. master mode block diagram shift register spck mosi lsb msb miso spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0..3 cpol ncpha bits 0 1 fdiv mck mck/n baud rate generator spi_csr0..3 scbr npcs3 npcs0 npcs2 npcs1 npcs0 0 1 ps spi_mr pcs spi_tdr pcs modf current peripheral spi_rdr pcs spi_csr0..3 csaat pcsdec modfdis mstr
294 32054f?avr32?09/09 at32ap7002 20.7.3.2 master mode flow diagram figure 20-6. master mode flow diagram s spi enable csaat ? ps ? 1 0 0 1 1 npcs = spi_tdr(pcs) npcs = spi_mr(pcs) delay dlybs serializer = spi_tdr(td) tdre = 1 data transfer spi_rdr(rd) = serializer rdrf = 1 tdre ? npcs = 0xf delay dlybcs fixed peripheral variable peripheral delay dlybct 0 1 csaat ? 0 tdre ? 1 0 ps ? 0 1 spi_tdr(pcs) = npcs ? no yes spi_mr(pcs) = npcs ? no npcs = 0xf delay dlybcs npcs = spi_tdr(pcs) npcs = 0xf delay dlybcs npcs = spi_mr(pcs), spi_tdr(pcs) fixed peripheral variable peripheral - npcs defines the current chip select - csaat, dlybs, dlybct refer to the fields of the chip select register corresponding to the current chip select - when npcs is 0xf, csaat is 0.
295 32054f?avr32?09/09 at32ap7002 20.7.3.3 clock generation the spi baud rate clock is generated by dividing the master clock (mck) or the master clock divided by 32, by a value between 1 and 255. the selection between master clock or master clock divided by 32 is done by the fdiv value set in the mode register this allows a maximum operating baud rate at up to master clock and a minimum operating baud rate of mck divided by 255*32. programming the scbr field at 0 is forbidden. tr iggering a transfer while scbr is at 0 can lead to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. the divisor can be defined independently for each chip select, as it has to be programmed in the scbr field of the chip select registers. this allows the spi to automatically adapt the baud rate for each interfaced peripheral without reprogramming. 20.7.3.4 transfer delays figure 20-7 shows a chip select transfer change and consecutive transfers on the same chip select. three delays can be programmed to modify the transfer waveforms: ? the delay between chip selects, programmable only once for all the chip selects by writing the dlybcs field in the mode register. allows insertion of a delay between release of one chip select and before assertion of a new one. ? the delay before spck, independently programmable for each chip select by writing the field dlybs. allows the start of spck to be delayed after the chip select has been asserted. ? the delay between consecutive transfers, independently programmable for each chip select by writing the dlybct field. allows insertion of a delay between two transfers occurring on the same chip select these delays allow the spi to be adapted to the interfaced peripherals and their speed and bus release time. figure 20-7. programmable delays dlybcs dlybs dlybct dlybct chip select 1 chip select 2 spck
296 32054f?avr32?09/09 at32ap7002 20.7.3.5 peripheral selection the serial peripherals are selected through the assertion of the npcs0 to npcs3 signals. by default, all the npcs signals are high before and after each transfer. the peripheral selection can be performed in two different ways: ? fixed peripheral select: spi exchanges data with only one peripheral ? variable peripheral select: data can be exchanged with more than one peripheral fixed peripheral select is activated by writing t he ps bit to zero in mr (mode register). in this case, the current peripheral is defined by the pc s field in mr and the pcs field in tdr have no effect. variable peripheral select is activated by setting ps bit to one. the pcs field in tdr is used to select the current peripheral. this means that the peripheral selection can be defined for each new data. the fixed peripheral selection allows buffer transfers with a single peripheral. using the pdc is an optimal means, as the size of the data transfer between the memory and the spi is either 8 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple peripherals without repro- gramming the mode register. data written in tdr is 32 bits wide and defines the real data to be transmitted and the peripheral it is destined to. using the pdc in this mo de requires 32-bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, however the spi still controls the number of bi ts (8 to16) to be tr ansferred through miso and mosi lines with the chip select configuration registers. this is not the optimal means in term of memory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor. 20.7.3.6 peripheral chip select decoding the user can program the spi to operate with up to 15 peripherals by decoding the four chip select lines, npcs0 to npcs3 with an external l ogic. this can be enabled by writing the pcs- dec bit at 1 in the mode register (mr). when operating without decoding, the spi makes sure that in any case only one chip select line is activated, i.e. driven low at a time. if two bits are defined low in a pcs field, only the lowest numbered chip select is driven low. when operating with decoding, the spi directly outputs the value defined by the pcs field of either the mode register or the transmit data register (depending on ps). as the spi sets a default value of 0xf on the chip select lines (i.e. all chip select lines at 1) when not processing any transfer, only 15 peripherals can be decoded. the spi has only four chip select registers, not 15. as a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. as an example, crs0 defines the characteristics of the externally decoded peripherals 0 to 3, corresponding to the pcs values 0x0 to 0x3. thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14.
297 32054f?avr32?09/09 at32ap7002 20.7.3.7 peripheral deselection when operating normally, as soon as the transfer of the last data written in tdr is completed, the npcs lines all rise. this might lead to runtime error if the processor is too long in responding to an interrupt, and thus might lead to difficulties for interfacing with some serial peripherals requiring the chip select li ne to remain active during a full set of transfers. to facilitate interfacing with such devices, the chip select regist er can be prog rammed with the csaat bit (chip select active afte r transfer) at 1. this allows th e chip select lines to remain in their current state (low = active) until transfer to another peripheral is required. figure 20-8 shows different peripheral deselection cases and the effect of the csaat bit. figure 20-8. peripheral deselection a npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs dlybct pcs=a a dlybcs dlybct a pcs = a a a dlybct aa csaat = 0 dlybct aa csaat = 1 a
298 32054f?avr32?09/09 at32ap7002 20.7.3.8 mode fault detection a mode fault is detected when the spi is programmed in master mode and a low level is driven by an external master on the npcs0/nss signa l. npcs0, mosi, miso and spck must be con- figured in open-drain through the pio controller, so that external pull up resistors are needed to guarantee high level. when a mode fault is detected, the modf bit in the sr is set until the sr is read and the spi is automatically disabled until re-enabled by writing the spien bit in the cr (control register) at 1. by default, the mode fault detection circuitr y is enabled. the user can disable mode fault detection by setting the modfdis bit in the spi mode register (mr). 20.7.4 spi slave mode when operating in slave mode, the spi processes data bits on the clock provided on the spi clock pin (spck). the spi waits for nss to go active before receiving the serial clock from an external master. when nss falls, the clock is validated on the serializer, which processes the number of bits defined by the bits field of the chip select register 0 (csr0). these bits are processed follow- ing a phase and a polarity defined respectively by the ncpha and cpol bits of the csr0. note that bits, cpol and ncpha of the other chip select registers have no effect when the spi is programmed in slave mode. the bits are shifted out on the miso line and sampled on the mosi line. when all the bits are processed, the received data is transferred in the receive data register and the rdrf bit rises. if rdrf is already high wh en the data is transf erred, the overrun bit rises and the data transfer to rdr is aborted. when a transfer starts, the data shifted out is the data present in the shift register. if no data has been written in the transmit data register (t dr), the last data received is transferred. if no data has been received since the last reset, all bits are transmitted low, as the shift register resets at 0. when a first data is written in tdr, it is trans ferred immediately in the shift register and the tdre bit rises. if new data is wr itten, it remains in tdr until a transfer occurs, i.e. nss falls and there is a valid clock on the spck pin. when the transfer occurs, the last data written in tdr is transferred in the shift register and the tdre bit rises. this enables frequent updates of critical variables with single transfers. then, a new data is loaded in the shift register from the transmit data register. in case no character is ready to be transmitted, i.e. no c haracter has been written in tdr since the last load from tdr to the shift register, the shift register is not modified and the last received character is retransmitted. figure 20-9 shows a block diagram of the spi when operating in slave mode.
299 32054f?avr32?09/09 at32ap7002 figure 20-9. slave mode functional block diagram shift register spck spiens lsb msb nss mosi spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0 cpol ncpha bits fload spien spidis miso
300 32054f?avr32?09/09 at32ap7002 20.8 serial peripheral inte rface (spi) user interface note: 1. values in the version register vary wit h the version of the ip block implementation. table 20-3. spi register mapping offset register register name access reset 0x00 control register cr write-only --- 0x04 mode register mr read/write 0x0 0x08 receive data register rdr read-only 0x0 0x0c transmit data register tdr write-only --- 0x10 status register sr read-only 0x000000f0 0x14 interrupt enable register ier write-only --- 0x18 interrupt disable register idr write-only --- 0x1c interrupt mask register imr read-only 0x0 0x20 - 0x2c reserved 0x30 chip select register 0 csr0 read/write 0x0 0x34 chip select register 1 csr1 read/write 0x0 0x38 chip select register 2 csr2 read/write 0x0 0x3c chip select register 3 csr3 read/write 0x0 0x004c - 0x00f8 reserved ? ? ? 0x00fc version register version read-only 0x- (1) 0x100 - 0x124 reserved for the pdc
301 32054f?avr32?09/09 at32ap7002 20.8.1 spi control register name: cr access type: write-only ? spien: spi enable 0 = no effect. 1 = enables the spi to transfer and receive data. ? spidis: spi disable 0 = no effect. 1 = disables the spi. as soon as spdis is set, spi finishes its transfer. all pins are set in input mode and no data is received or transmitted. if a transfer is in progress, the transfer is finished before the spi is disabled. if both spien and spidis are equal to one when the control register is written, the spi is disabled. ? swrst: spi software reset 0 = no effect. 1 = reset the spi. a software-triggered hardware reset of the spi interface is performed. the spi is in slave mode after a software reset. pdc channels are not affected by software reset. ? lastxfer: last transfer 0 = no effect. 1 = the current npcs will be deasserted afte r the character written in td has been transferred. when csaat is set, this allows to close the communication with the current serial peri pheral by raising the correspo nding npcs line as soon as td transfer has completed. 31 30 29 28 27 26 25 24 ???????lastxfer 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst?????spidisspien
302 32054f?avr32?09/09 at32ap7002 20.8.2 spi mode register name: mr access type: read/write ? mstr: master/slave mode 0 = spi is in slave mode. 1 = spi is in master mode. ? ps: peripheral select 0 = fixed peripheral select. 1 = variable peripheral select. ? pcsdec: chip select decode 0 = the chip selects are directly connected to a peripheral device. 1 = the four chip select lines are connected to a 4- to 16-bit decoder. when pcsdec equals one, up to 15 chip select signals can be generated with the four lines using an external 4- to 16-bit decoder. the chip select registers define the characteristics of the 15 chip selects according to the following rules: csr0 defines peripheral chip select signals 0 to 3. csr1 defines peripheral chip select signals 4 to 7. csr2 defines peripheral chip select signals 8 to 11. csr3 defines peripheral chip select signals 12 to 14. ? fdiv: clock selection 0 = the spi operates at mck. 1 = the spi operates at mck/n. ? modfdis: mode fault detection 0 = mode fault detection is enabled. 1 = mode fault detection is disabled. ? llb: local loopback enable 0 = local loopback path disabled. 1 = local loopback path enabled. llb controls the local loopback on the data serializer for test ing in master mode only. miso is internally connected to mosi. 31 30 29 28 27 26 25 24 dlybcs 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 ???????? 76543210 llb ? ? modfdis fdiv pcsdec ps mstr
303 32054f?avr32?09/09 at32ap7002 ? pcs: peripheral chip select this field is only used if fixed peripheral select is active (ps = 0). if pcsdec = 0: pcs = xxx0 npcs[3:0] = 1110 pcs = xx01 npcs[3:0] = 1101 pcs = x011 npcs[3:0] = 1011 pcs = 0111 npcs[3:0] = 0111 pcs = 1111 forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs. ? dlybcs: delay between chip selects this field defines the delay from npcs inactive to the ac tivation of another npcs. the dlybcs time guarantees non-over- lapping chip selects and solves bus contentions in case of peripherals having long data float times. if dlybcs is less than or equal to six, six mck periods (or 6*n mck period s if fdiv is set) will be inserted by default. otherwise, the following equat ion determines the delay: if fdiv is 0: if fdiv is 1: delay between chip selects dlybcs mck ---------------------- - = delay between chip selects dlybcs n mck --------------------------------- =
304 32054f?avr32?09/09 at32ap7002 20.8.3 spi receive data register name: rdr access type: read-only ? rd: receive data data received by the spi interface is stored in this register right-justified. unused bits read zero. ? pcs: peripheral chip select in master mode only, these bits indicate the value on the npcs pins at the end of a transfer. otherwise, these bits read zero. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 rd 76543210 rd
305 32054f?avr32?09/09 at32ap7002 20.8.4 spi transmit data register name: tdr access type: write-only ? td: transmit data data to be transmitted by the spi interface is stored in this register. information to be transmitted must be written to the transmit data register in a right-justified format. ? pcs: peripheral chip select this field is only used if variable peripheral select is active (ps = 1). if pcsdec = 0: pcs = xxx0 npcs[3:0] = 1110 pcs = xx01 npcs[3:0] = 1101 pcs = x011 npcs[3:0] = 1011 pcs = 0111 npcs[3:0] = 0111 pcs = 1111 forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs ? lastxfer: last transfer 0 = no effect. 1 = the current npcs will be deasserted afte r the character written in td has been transferred. when csaat is set, this allows to close the communication with the current serial peri pheral by raising the correspo nding npcs line as soon as td transfer has completed. this field is only used if variable peripheral select is active (ps = 1). 31 30 29 28 27 26 25 24 ???????lastxfer 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 td 76543210 td
306 32054f?avr32?09/09 at32ap7002 20.8.5 spi status register name: sr access type: read-only ? rdrf: receive data register full 0 = no data has been received since the last read of rdr 1 = data has been received and the receiv ed data has been transferred from the serializer to rdr since the last read of rdr. ? tdre: transmit data register empty 0 = data has been written to tdr and not yet transferred to the serializer. 1 = the last data written in the transmit data register has been transferred to the serializer. tdre equals zero when the spi is disabled or at reset. the spi enable command sets this bit to one. ? modf: mode fault error 0 = no mode fault has been detected since the last read of sr. 1 = a mode fault occurred since the last read of the sr. ? ovres: overrun error status 0 = no overrun has been detected since the last read of sr. 1 = an overrun has occurred since the last read of sr. an overrun occurs when rdr is loaded at least twice from the seri alizer since the last read of the rdr. ? endrx: end of rx buffer 0 = the receive counter register has not reach ed 0 since the last write in rcr or rncr. 1 = the receive counter register has reached 0 since the last write in rcr or rncr. ? endtx: end of tx buffer 0 = the transmit counter register has not reache d 0 since the last write in tcr or tncr. 1 = the transmit counter register has reached 0 since the last write in tcr or tncr. ? rxbuff: rx buffer full 0 = rcr or rncr has a value other than 0. 1 = both rcr and rncr has a value of 0. ? txbufe: tx buffer empty 0 = tcr or tncr has a value other than 0. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????spiens 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
307 32054f?avr32?09/09 at32ap7002 1 = both tcr and tncr has a value of 0. ? nssr: nss rising 0 = no rising edge detected on nss pin since last read. 1 = a rising edge occurred on nss pin since last read. ? txempty: transmission registers empty 0 = as soon as data is written in tdr. 1 = tdr and internal shifter are empty. if a transfer delay has been defined, txempty is set after the completion of such delay. ? spiens: spi enable status 0 = spi is disabled. 1 = spi is enabled.
308 32054f?avr32?09/09 at32ap7002 20.8.6 spi interrupt enable register name: ier access type: write-only ? rdrf: receive data register full interrupt enable ? tdre: spi transmit data regi ster empty interrupt enable ? modf: mode fault error interrupt enable ? ovres: overrun error interrupt enable ? endrx: end of receive bu ffer interrupt enable ? endtx: end of transmit buffer interrupt enable ? rxbuff: receive buffer full interrupt enable ? txbufe: transmit buffer empty interrupt enable ? txempty: transmission registers empty enable ? nssr: nss rising interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
309 32054f?avr32?09/09 at32ap7002 20.8.7 spi interrupt disable register name: idr access type: write-only ? rdrf: receive data register full interrupt disable ? tdre: spi transmit data register empty interrupt disable ? modf: mode fault error interrupt disable ? ovres: overrun error interrupt disable ? endrx: end of receive bu ffer interrupt disable ? endtx: end of transmit buffer interrupt disable ? rxbuff: receive buffer full interrupt disable ? txbufe: transmit buffer empty interrupt disable ? txempty: transmission registers empty disable ? nssr: nss rising interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
310 32054f?avr32?09/09 at32ap7002 20.8.8 spi interrupt mask register name: imr access type: read-only ? rdrf: receive data register full interrupt mask ? tdre: spi transmit data register empty interrupt mask ? modf: mode fault error interrupt mask ? ovres: overrun error interrupt mask ? endrx: end of receive buffer interrupt mask ? endtx: end of transmit buffer interrupt mask ? rxbuff: receive buffer full interrupt mask ? txbufe: transmit buffer empty interrupt mask ? txempty: transmission registers empty mask ? nssr: nss rising interrupt mask 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
311 32054f?avr32?09/09 at32ap7002 20.8.9 spi chip select register name: csr0... csr3 access type: read/write ? cpol: clock polarity 0 = the inactive state value of spck is logic level zero. 1 = the inactive state value of spck is logic level one. cpol is used to determine the inactive state value of the serial clock (spck). it is used with ncpha to produce the required clock/data relationship between master and slave devices. ? ncpha: clock phase 0 = data is changed on the leading edge of spck and captured on the following edge of spck. 1 = data is captured on the leading edge of spck and changed on the following edge of spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the required clock/da ta relationship between master and slave devices. ? csaat: chip select active after transfer 0 = the peripheral chip select line rises as soon as the last transfer is achieved. 1 = the peripheral chip select does not rise after the last transfer is achieved. it remains active until a new transfer is requested on a different chip select. ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used, see table 20-4 on page 312 . 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat ? ncpha cpol
312 32054f?avr32?09/09 at32ap7002 . ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to derive the spck baud rate from the master clock mck. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: if fdiv is 0: if fdiv is 1: note: n = 32 programming the scbr field at 0 is forbidden. triggering a trans fer while scbr is at 0 can le ad to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. table 20-4. bits, bits per transfer bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 reserved 1010 reserved 1011 reserved 1100 reserved 1101 reserved 1110 reserved 1111 reserved spck baudrate mck scbr -------------- - = spck baudrate mck nscbr () ------------------------------ =
313 32054f?avr32?09/09 at32ap7002 otherwise, the following equations determine the delay: if fdiv is 0: if fdiv is 1: note: n = 32 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers with the same perip heral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transf ers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equat ion determines the delay: if fdiv is 0: if fdiv is 1: note: n = 32 delay before spck dlybs mck ------------------ - = delay before spck ndlybs mck ---------------------------- - = delay between consecutive transfers 32 dlybct mck ------------------------------------ scbr 2 mck ---------------- - + = delay between consecutive transfers 32 n dlybct mck ---------------------------------------------- - nscbr 2 mck ------------------------- + =
314 32054f?avr32?09/09 at32ap7002 21. two-wire interface (twi) rev: 1.8.0.1 21.1 features ? compatible with philips? i 2 c protocol ? one, two or three bytes for slave address ? sequential read/write operations 21.2 description the two-wire interface (twi) interconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 400 kbits per second, based on a byte-ori- ented transfer format. it can be used with any atme l two-wire bus serial eeprom. the twi is programmable as a master with sequential or single-byte access. a configurable baud rate gen- erator permits the output data rate to be adapted to a wide range of core clock frequencies. 21.3 block diagram figure 21-1. block diagram 21.4 application block diagram figure 21-2. application block diagram peripheral bus bridge power manager mck two-wire interface pio interrupt controller twi interrupt twck twd host with twi interface twd twck at24lc16 u1 at24lc16 u2 lcd controller u3 slave 1 slave 2 slave 3 rr vdd
315 32054f?avr32?09/09 at32ap7002 21.4.1 i/o lines description 21.5 product dependencies 21.5.1 i/o lines both twd and twck are bi-directional lines, connected to a positive supply voltage via a cur- rent source or pull-up resistor (see figure 21-2 on page 314 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open- collector to perform the wired-and function. twd and twck pins may be multiplexed with pi o lines. to enable the twi, the programmer must program the pio controller to dedicate twd and twck as peripheral lines. 21.5.2 power management the twi clock is generated by the power manager. before using the twi, the programmer must ensure that the twi clock is enabled in the power manager. in the twi description, master clock (mck) is the clock of the peripheral bus to which the twi is connected. 21.5.3 interrupt the twi interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the twi. table 21-1. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output
316 32054f?avr32?09/09 at32ap7002 21.6 functional description 21.6.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 21-4 on page 316 ). each transfer begins with a start condition and terminates with a stop condition (see figure 21-3 on page 316 ). ?a high-to-low transition on the twd line while twck is high defines the start condition. ?a low-to-high transition on the twd line while twck is high defines a stop condition. figure 21-3. start and stop conditions figure 21-4. transfer format 21.6.2 modes of operation the twi has two modes of operation: ?master transmitter mode ?master receiver mode the twi control register (cr) allows configurat ion of the interface in master mode. in this mode, it generates the clock according to the value programmed in the clock waveform gener- ator register (cwgr). this register defines the twck signal completely, enabling the interface to be adapted to a wide range of clocks. 21.6.3 transmitting data after the master initiates a start condition, it sends a 7-bit slave address, configured in the mas- ter mode register (dadr in mmr), to notify th e slave device. the bit following the slave address indicates the transfer direction (write or read). if this bit is 0, it indicates a write operation (trans- mit operation). if the bit is 1, it indicate s a request for data read (receive operation). the twi transfers require the slave to acknowledge each received byte. during the acknowl- edge clock pulse, the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. the master polls the data line during this clock pulse and sets the nak bit in the status register if the slave does not acknowledge the byte. as with the twd twck start stop twd twck start address r/w ack data ack data ack stop
317 32054f?avr32?09/09 at32ap7002 other status bits, an interrupt can be generated if enabled in the interrupt enable register (ier). after writing in the transmit-holding register (thr ), setting the start bit in the control register starts the transmission. the data is shifted in the internal shifter and when an acknowledge is detected, the txrdy bit is set un til a new write in the thr (see figure 21-6 below). the master generates a stop condition to end the transfer. the read sequence begins by setting the start bit. when the rxrdy bit is set in the status register, a character has been received in the receive-holding register (rhr). the rxrdy bit is reset when reading the rhr. the twi interface performs various transfer formats (7-bit slave address, 10-bit slave address). the three internal address bytes are configurable through the master mode register (mmr). if the slave device supports only a 7-bit address, iadrsz must be set to 0. for a slave address higher than 7 bits, the user must configure the address size (iadrsz ) and set the other slave address bits in the internal address register (iadr). figure 21-5. master write with one, two or three bytes internal address and one data byte figure 21-6. master write with one byte internal address and multiple data bytes figure 21-7. master read with one, two or three bytes internal address and one data byte s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a data a p s dadr w a iadr(15:8) a iadr(7:0) a p data a a iadr(7:0) a p data a s dadr w twd three bytes internal address two bytes internal address one byte internal address twd twd a iadr(7:0) a data a s dadr w data a p data a txcomp txrdy write thr write thr write thr write thr twd s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a s dadr w a iadr(15:8) a iadr(7:0) a a iadr(7:0) a s dadr w data n p s dadr r a s dadr r a data n p s dadr r a data n p twd twd twd three bytes internal address two bytes internal address one byte internal address
318 32054f?avr32?09/09 at32ap7002 figure 21-8. master read with one byte internal address and multiple data bytes ?s = start ?p = stop ?w = write ?r = read ?a = acknowledge ?n = not acknowledge ?dadr= device address ?iadr = internal address figure 21-9 below shows a byte write to an atmel at24lc512 eeprom. this demonstrates the use of internal addresses to access the device. figure 21-9. internal address usage a iadr(7:0) a s dadr w s dadr r a data a data n p txcomp write start bit rxrdy write stop bit read rhr read rhr twd s t a r t m s b device address 0 l s b r / w a c k m s b w r i t e a c k a c k l s b a c k first word address second word address data s t o p
319 32054f?avr32?09/09 at32ap7002 21.6.4 read/write flowcharts the following flowcharts shown in figure 21-10 on page 319 and in figure 21-11 on page 320 give examples for read and write operations in master mode. a polling or interrupt method can be used to check the status bits. the interrupt method requires that the interrupt enable register (ier) be configured first. figure 21-10. twi write in master mode set twi clock: cwgr = clock set the control register: - master enable cr = msen set the master mode register: - device slave address - internal address size - transfer direction bit write ==> bit mread = 0 internal address size = 0? load transmit register thr = data to send read status register txrdy = 0? data to send? read status register txcomp = 0? end start set theinternal address iadr = address ye s thr = data to send ye s ye s ye s
320 32054f?avr32?09/09 at32ap7002 figure 21-11. twi read in master mode set twi clock: cwgr = clock set the control register: - master enable cr = msen set the master mode register: - device slave address - internal address size - transfer direction bit read ==> bit mread = 0 internal address size = 0? start the transfer cr = start stop the transfer cr = stop read status register rxrdy = 0? data to read? read status register txcomp = 0? end start set the internal address iadr = address ye s ye s ye s ye s read rhr
321 32054f?avr32?09/09 at32ap7002 21.7 twi user interface 21.7.1 register mapping table 21-2. two-wire interface (twi) user interface offset register name access reset value 0x0000 control register cr write-only n/a 0x0004 master mode register mmr read/write 0x0000 0x0008 reserved - - - 0x000c internal address register iadr read/write 0x0000 0x0010 clock waveform generator register cwgr read/write 0x0000 0x0020 status register sr read-only 0x0008 0x0024 interrupt enable register ier write-only n/a 0x0028 interrupt disable register idr write-only n/a 0x002c interrupt mask register imr read-only 0x0000 0x0030 receive holding register rhr read-only 0x0000 0x0034 transmit holding register thr read/write 0x0000
322 32054f?avr32?09/09 at32ap7002 21.7.2 twi control register register name :cr access type: write-only ? start: send a start condition 0 = no effect. 1 = a frame beginning with a start bit is transmitted according to the settings in the mode register. this action is necessary when the twi peripheral wants to read data from a slave. when configured in master mode with a write operation, a frame is sent with the mode register as soon as the user writes a character in the holding register. ? stop: send a stop condition 0 = no effect. 1 = stop condition is sent just after completing the current byte transmission in master read or write mode. in single data byte master read or write, the start and stop must both be set. in multiple data bytes master read or write, the stop must be set before ack/nack bit transmission. in master read mode, if a nack bit is received, the stop is automatically performed. in multiple data write operation, when both thr and shift register are empty, a stop condition is automatically sent. ? msen: twi master transfer enabled 0 = no effect. 1 = if msdis = 0, the master data transfer is enabled. ? msdis: twi master transfer disabled 0 = no effect. 1 = the master data transfer is disabled, all pending data is tr ansmitted. the shifter and holding characters (if they contain data) are transmitted in case of write operation. in read operation, the character being transferred must be completely received before disabling. ? swrst: software reset 0 = no effect. 1 = equivalent to a system reset. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst ? ? ? msdis msen stop start
323 32054f?avr32?09/09 at32ap7002 21.7.3 twi master mode register register name :mmr address type : read/write ? iadrsz: internal device address size ? mread: master read direction 0 = master write direction. 1 = master read direction. ? dadr: device address the device address is used in master mode to access slave devices in read or write mode. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ?dadr 15 14 13 12 11 10 9 8 ???mread?? iadrsz 76543210 ???????? iadrsz[9:8] 0 0 no internal device address (byte command protocol) 0 1 one-byte internal device address 1 0 two-byte internal device address 1 1 three-byte internal device address
324 32054f?avr32?09/09 at32ap7002 21.7.4 twi internal address register register name :iadr access type : read/write ? iadr: internal address 0, 1, 2 or 3 bytes depending on iadrsz. ? low significant byte address in 10-bit mode addresses. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 iadr 15 14 13 12 11 10 9 8 iadr 76543210 iadr
325 32054f?avr32?09/09 at32ap7002 21.7.5 twi clock waveform generator register register name :cwgr access type : read/write ? cldiv: clock low divider the scl low period is defined as follows: ? chdiv: clock high divider the scl high period is defined as follows: ? ckdiv: clock divider the ckdiv is used to increase both scl high and low periods. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? ckdiv 15 14 13 12 11 10 9 8 chdiv 76543210 cldiv t low cldiv ( 2 ckdiv () 3 ) + t mck = t high chdiv ( 2 ckdiv () 3 ) + t mck =
326 32054f?avr32?09/09 at32ap7002 21.7.6 twi status register register name :sr access type : read-only ? txcomp: transmission completed 0 = in master, during the length of the current frame. in slave, from start received to stop received. 1 = when both holding and shift registers are empty and stop condition has been sent (in master), or when msen is set (enable twi). ? rxrdy: receive hold ing register ready 0 = no character has been received since the last rhr read operation. 1 = a byte has been received in therhr since the last read. ? txrdy: transmit holding register ready 0 = the transmit holding register has not been transferred into shift register. set to 0 when writing into thr register. 1 = as soon as data byte is transferred from thr to internal shifter or if a nack error is detected, txrdy is set at the same time as txcomp and nack. txrdy is also set when msen is set (enable twi). ? nack: not acknowledged 0 = each data byte has been correctly received by the far-end side twi slave component. 1 = a data byte has not been acknowledged by the slave compo nent. set at the same time as txcomp. reset after read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
327 32054f?avr32?09/09 at32ap7002 21.7.7 twi interrupt enable register register name :ier access type: write-only ? txcomp: transmission completed ? rxrdy: receive hold ing register ready ? txrdy: transmit holding register ready ? nack: not acknowledge 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
328 32054f?avr32?09/09 at32ap7002 21.7.8 twi interrupt disable register register name :idr access type: write-only ? txcomp: transmission completed ? rxrdy: receive hold ing register ready ? txrdy: transmit holding register ready ? nack: not acknowledge 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
329 32054f?avr32?09/09 at32ap7002 21.7.9 twi interrupt mask register register name :imr access type : read-only ? txcomp: transmission completed ? rxrdy: receive hold ing register ready ? txrdy: transmit holding register ready ? nack: not acknowledge 0 = the corresponding interrupt is disabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
330 32054f?avr32?09/09 at32ap7002 21.7.10 twi receive holding register register name : rhr access type : read-only ? rxdata: master or slave receive holding data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 rxdata
331 32054f?avr32?09/09 at32ap7002 21.7.11 twi transmit holding register register name :thr access type: read/write ? txdata: master or slave transmit holding data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 txdata
332 32054f?avr32?09/09 at32ap7002 22. ps/2 module (psif) rev: 1.0.0.2 22.1 features ? ps/2 host ? receive and transmit capability ? parity generation and error detection ? overrun error detection 22.2 description the ps/2 module provides host functionality allowing the mcu to interface ps/2 devices such as keyboard and mice. the module is capable of both host-to-device and device-to-host communication. 22.3 product dependencies 22.3.1 i/o lines the ps/2 may be multiplexed with pio lines. the programmer must first program the pio con- troller to give control of the pins to the ps/2 module. 22.3.2 power management the clock for the ps/2 module is generated by the power manager. the programmer must ensure that the ps/2 clock is enabled in the power manager before using the ps/2 module. 22.3.3 interrupt the ps/2 module has an interrupt line connected to the interrupt controller. handling the ps/2 interrupt requires programming the interrupt controller before configuring the ps/2 module. 22.4 the ps/2 protocol the ps/2 protocol is a bidirectional synchronous serial communication protocol. it connects a single master - referred to as the ?host? - to a single slave - referred to as the ?device?. communi- cation is done through two lines called ?data? and ?clock?. both of these must be open-drain or open-collector with a pullup resistor to perform a wired-and function. when the bus is idle, both lines are high. the device always generates the clock signal, but the host may pull the clock low to inhibit trans- fers. the clock frequency is in the range 10-16.7 khz. both the host and the slave may initiate a transfer, but the host has ultimate control of the bus. data are transmitted one byte at a time in a frame consisting of 11-12 bits. the transfer format is described in detail below. 22.4.1 device to host communication the device can only initiate a transfer when the bus is idle. if the host at any time pulls the clock low, the device must stop transferring data and prepare to receive data from the host. the device transmits data using a 11-bit frame. t he device writes a bit on the data line when the clock is high, and the host reads the bit when the clock is low. the format of the frame is:
333 32054f?avr32?09/09 at32ap7002 ? 1 start bit - always 0. ? 8 data bits, least significant bit first. ? 1 parity bit - odd parity. ? 1 stop bit - always 1. figure 22-1. device to host transfer 22.4.2 host to device communication because the device always generates the clock, host to device communication is done differ- ently than device to host communication. ? the host starts by inhibiting communicati on by pulling clock low for a minimum of 100 microseconds. ? then applies a ?request-to-send? by releasing clock and pulling data low. the device must check for this state at least ev ery 10 milliseconds. once it detects a request-to- send, it must start generating the clock and receive one frame of data. the host writes a data bit when the clock is low, and the device reads the bit when the clock is high. the format of the frame is: ? 1 start bit - always 0. ? 8 data bits - least significant bit first. ? 1 parity bit - odd parity ? 1 stop bit - always one. ? 1 acknowledge bit - the device acknowledges by pulling data low. start bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 7 stop bit 6 clock data parity
334 32054f?avr32?09/09 at32ap7002 figure 22-2. host to device transfer 22.5 functional description 22.5.1 prescaler for all data transfers on the ps/2 bus, the dev ice is responsible for generating the clock and thus controlling the timing of th e communications. when a host wa nts to initiate a transfer how- ever, it needs to pull the clock line low for a given time (minimum 100s). a clock prescaler controls the timing of the transfer request pulse. before initiating host to device transfers, the programmer must write psr (prescale register). this value determines the length of the ?transfer request? pulse and is found by: prscv = pulse length * ps/2 module frequency according to the ps/2 specifications, the pulse length should be at least 100s. the ps/2 mod- ule frequency is the frequency of the peripheral bus to which the module is connected. 22.5.2 receiving data the receiver is enabled by writing the rxen bi t in cr (control register) to ?1?. when enabled, the receiver will continuously receiv e data transmitted by the device . the data is stored in rhr (receive holding register). when a byte has been received, the rxrdy bit in sr (status reg- ister) is set. for each received byte, the parity is calculated. if it doesn?t match the parity bit received from the device, the parity bit in sr is set. the received byte should then be discarded. if a received byte in rhr is not read before a new byte has been received, the overrun bit - ovrun in sr is set. the new data is stored in rhr overwriting the previously received byte. 22.5.3 transmitting data the transmitter is enabled by writing the txen bit in cr to ?1?. when enabled, a data transfer to the device will be started by wr iting the transmit data to thr (transmit holding register). any ongoing transfer from the device will be aborted. start bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 stop bit 6 inhibit ack clock data host clock host data device clock device data bit 7 parity
335 32054f?avr32?09/09 at32ap7002 when the data written to thr has been transmitted to the device, the txrdy bit in sr will be set and a new value can be loaded into thr. at the end of the transfer, the device should acknowledge the transfer by pulling the data line low for one cycle. if an acknowledge is not detected, the nack bit in sr will be set. if the device fails to a cknowledge the frame, th e nack bit in sr will be set. the software is responsible for any retries. all transfers from host to device are started by the host pulling the clock line low for at least 100s. the programmer must ensure that the prescaler is programmed to generate correct pulse length. 22.5.4 interrupts the ps/2 module can be configured to signal an interrupt when one of the bits in sr is set. the interrupt is enabled by writing to ier (interrupt enable register) and disabled by writing to idr (interrupt disable register). the current setting of an interrupt line can be seen by reading imr (interrupt mask register). 22.6 user interface offset register register name access reset 0x000 ps/2 control register 0 cr0 write-only - 0x004 ps/2 receive holding register 0 rhr0 read-only 0x0 0x008 ps/2 transmit holding register 0 thr0 write-only - 0x00c reserved - - - 0x010 ps/2 status register 0 sr0 read-only 0x0 0x014 ps/2 interrupt enable register 0 ier0 write-only - 0x018 ps/2 interrupt disable register 0 idr0 write-only - 0x01c ps/2 interrupt mask register 0 imr0 read-only 0x0 0x020 reserved - - - 0x024 ps/2 prescale register 0 psr0 read/write 0x0 0x100 ps/2 control register 1 cr1 write-only - 0x104 ps/2 receive holding register 1 rhr1 read-only 0x0 0x108 ps/2 transmit holding register 1 thr1 write-only - 0x10c reserved - - - 0x110 ps/2 status register 1 sr1 read-only 0x0 0x114 ps/2 interrupt enable register 1 ier1 write-only - 0x118 ps/2 interrupt disable register 1 idr1 write-only - 0x11c ps/2 interrupt mask register 1 imr1 read-only 0x0 0x120 reserved - - - 0x124 ps/2 prescale register 1 psr1 read/write 0x0
336 32054f?avr32?09/09 at32ap7002 22.6.1 ps/2 control register name: cr0, cr1 access type: write-only ? swrst: software reset writing this strobe causes a reset of the ps/2 interface module. data shift registers are cleared and configuration registers a re reset to default values. ? txdis: transmitter disable 0: no effect. 1: disables the transmitter. ? txen: transmitter enable 0: no effect. 1: enables the transmitter if txdis=0. ? rxdis: receiver disable 0: no effect. 1: disables the receiver. ? rxen: receiver enable 0: no effect. 1: enables the receiver if rxdis=0. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 swrst - - - - - txdis txen 76543210 ------rxdisrxen
337 32054f?avr32?09/09 at32ap7002 22.6.2 ps/2 receive holding register name: rhr0, rhr1 access type: read-only ? rxdata: receive data data received from the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
338 32054f?avr32?09/09 at32ap7002 22.6.3 ps/2 transmit holding register name: thr0, thr1 access type: write-only ? txdata: transmit data data to be transmitted to the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
339 32054f?avr32?09/09 at32ap7002 22.6.4 ps/2 status register name: sr0, sr1 access type: read-only ? parity: 0: no parity errors detected on incoming data since last read of sr. 1: at least one parity error detected on incoming data since last read of sr. ? nack: not acknowledge 0: all transmissions has been properly acknowle dged by the device since last read of sr. 1: at least one transmission was not properly acknowledged by the device since last read of sr. ? ovrun: overrun 0: no receive overrun has occured since the last read of sr. 1: at least one receive overrun condition has occured since the last read of sr. ? rxrdy: receiver ready 0: rhr is empty. 1: rhr contains valid data received from the device. ? txempty: transmitter empty 0: data remains in thr or is currently being transmitted from the shift register. 1: both thr and the sh ift register are empty. ? txrdy: transmitter ready 0: data has been loaded in thr and is waiting to be loaded into the shift register. 1: thr is empty. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
340 32054f?avr32?09/09 at32ap7002 22.6.5 ps/2 interrupt enable register name: ier0, ier1 access type: write-only ? parity: parity interrupt enable ? nack: not acknowledge interrupt enable ? ovrun: overrun interrupt enable ? rxrdy: overrun interrupt enable ? txempty: overrun interrupt enable ? txrdy: overrun interrupt enable 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
341 32054f?avr32?09/09 at32ap7002 ? 22.6.6 ps/2 interrupt disable register name: idr0, idr1 access type: write-only ? parity: parity interrupt disable ? nack: not acknowledge interrupt disable ? ovrun: overrun interrupt disable ? rxrdy: overrun interrupt disable ? txempty: overrun interrupt disable ? txrdy: overrun interrupt disable 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
342 32054f?avr32?09/09 at32ap7002 22.6.7 ps/2 interrupt mask register name: imr0, imr1 access type: read-only ? parity: parity interrupt mask ? nack: not acknowledge interrupt mask ? ovrun: overrun interrupt mask ? rxrdy: overrun interrupt mask ? txempty: overrun interrupt mask ? txrdy: overrun interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
343 32054f?avr32?09/09 at32ap7002 22.6.8 ps/2 prescale register name: psr0, psr1 access type: read/write ? prscv: prescale value 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ---- prscv 76543210 prscv
344 32054f?avr32?09/09 at32ap7002 23. synchronous serial controller (ssc) rev: 2.0.0.2 23.1 features ? provides serial synchronous communication links used in audio and telecom applications ? contains an independent receiver and transmitter an d a common clock divider ? interfaced with two pdca channels (dma access) to reduce processor overhead ? offers a configurable frame sync and data length ? receiver and transmitter can be programmed to st art automatically or on detection of different events on the frame sync signal ? receiver and transmitter includ e a data signal, a cl ock signal and a frame synchronization signal 23.2 overview the atmel synchronous serial controller (ssc ) provides a synchronous communication link with external devices. it supports many serial synchronous communication protocols generally used in audio and telecom applications such as i2s, short frame sync, long frame sync, etc. the ssc contains an independent receiver and transmitter and a common clock divider. the receiver and the transmitter each interface with three signals: the tx_data/rx_data signal for data, the tx_clock/rx_clock signal for the clock and the tx_frame_sync/rx_frame_sync signal for the frame sync. the transfers can be pro- grammed to start automatically or on different events detected on the frame sync signal. the ssc?s high-level of programmability and its two dedicated pdca channels of up to 32 bits permit a continuous high bit rate data transfer without processor intervention. featuring connection to two pdca channels, the ssc permits interfacing with low processor overhead to the following: ?codec?s in master or slave mode ?dac through dedicated serial interface, particularly i2s ?magnetic card reader
345 32054f?avr32?09/09 at32ap7002 23.3 block diagram figure 23-1. block diagram 23.4 application block diagram figure 23-2. application block diagram ssc interface pdca peripheral bus bridge hi gh speed bus peripheral bus power manager clk_ssc pio interrupt control ssc interrupt tx_frame_sync rx_frame_sync tx_clock rx_clock rx_data tx_data test management line interface interrupt management frame management time slot management ssc power management codec serial audio os or rtos driver
346 32054f?avr32?09/09 at32ap7002 23.5 i/o lines description 23.6 product dependencies 23.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with pio lines. before using the ssc receiver, the pio contro ller must be configured to dedicate the ssc receiver i/o lines to the ssc peripheral mode. before using the ssc transmitter, the pio controller must be configured to dedicate the ssc transmitter i/o lines to the ssc peripheral mode. 23.6.2 power management the ssc clock is generated by the power manager. before using the ssc, the programmer must ensure that the ssc clock is enabled in the power manager. in the ssc description, master clock (clk_ssc) is the bus clock of the peripheral bus to which the ssc is connected. 23.6.3 interrupt the ssc interface has an interrupt line connected to the interrupt controller. handling interrupts requires programming the interrupt controller before configuring the ssc. all ssc interrupts can be enabled/disabled configur ing the ssc interrupt mask register. each pending and unmasked ssc interrupt will assert the ssc interrupt line. the ssc interrupt ser- vice routine can get the interrupt origin by reading the ssc interrupt status register. 23.7 functional description this chapter contains the functional description of the following: ssc functional block, clock management, data format, start, transmitter, receiver and frame sync. the receiver and transmitter operate separately. however, they can work synchronously by pro- gramming the receiver to use the transmit clock and/or to start a data transfer when transmission starts. alternatively, this can be done by programming the transmitter to use the receive clock and/or to start a data transfer when reception starts. the transmitter and the receiver can be pro- grammed to operate with the clock signals provided on either the tx_clock or rx_clock pins. this allows the ssc to support many slave-mode data transfers. the maximum clock speed allowed on the tx_clock and rx_clock pins is the master clock divided by 2. table 23-1. i/o lines description pin name pin description type rx_frame_sync receiver fr ame synchro input/output rx_clock receiver clock input/output rx_data receiver data input tx_frame_sync transmitter frame synchro input/output tx_clock transmitter clock input/output tx_data transmitter data output
347 32054f?avr32?09/09 at32ap7002 figure 23-3. ssc functional block diagram 23.7.1 clock management the transmitter clock can be generated by: ?an external clock received on the tx_clock i/o pad ?the receiver clock ?the internal clock divider the receiver clock can be generated by: ?an external clock received on the rx_clock i/o pad ?the transmitter clock ?the internal clock divider furthermore, the transmitter block can generate an external clock on the tx_clock i/o pad, and the receiver block can generate an external clock on the rx_clock i/o pad. this allows the ssc to support many master and slave mode data transfers. clock divider user interface peripheral bus clk_ssc interrupt control start selector receive shift register receive holding register receive sync holding register pdca interrupt controller rx_frame_sync rx_data rx_clock frame sync controller clock output controller receive clock controller transmit holding register transmit sync holding register transmit shift register frame sync controller clock output controller transmit clock controller start selector tx_frame_sync rx_frame_sync tx_clock input transmitter tx_pdca load shift rx clock tx clock tx_clock tx_frame_sync tx_data receiver rx clock rx_clock input tx clock tx_frame_sync rx_frame_sync rx_pdca load shift
348 32054f?avr32?09/09 at32ap7002 23.7.1.1 clock divider figure 23-4. divided clock block diagram the master clock divider is determined by the 12-bit field div counter and comparator (so its maximal value is 4095) in the clock mode regist er cmr, allowing a master clock division by up to 8190. the divided clock is provided to both the receiver and transmitter. when this field is programmed to 0, the clock divider is not used and remains inactive. when div is set to a value equal to or greater than 1, the divided clock has a frequency of mas- ter clock divided by 2 times div. each level of the divided clock has a duration of the master clock multiplied by div. this ensures a 50 % duty cycle for the divided clock regardless of whether the div value is even or odd. figure 23-5. divided clock generation 23.7.1.2 transmitter clock management the transmitter clock is generated from the receiver clock or the divider clock or an external clock scanned on the tx_clock i/o pad. the transmitter clock is selected by the cks field in tcmr (transmit clock mode register). transmit clock can be inverted independently by the cki bits in tcmr. table 23-2. maximum minimum clk_ssc / 2 clk_ssc / 8190 cmr / 2 clk_ssc divided clock 12-bit counter clock divider master clock divided clock div = 1 master clock divided clock div = 3 divided clock frequency = clk_ssc/2 divided clock frequency = clk_ssc/6
349 32054f?avr32?09/09 at32ap7002 the transmitter can also drive the tx_clock i/o pad continuously or be limited to the actual data transfer. the clock output is configured by the tcmr register. the transmit clock inver- sion (cki) bits have no effect on the clock outputs. programming the tcmr register to select tx_clock pin (cks field) and at the same time continuous transmit clock (cko field) might lead to unpredi ctable results. figure 23-6. transmitter clock management 23.7.1.3 receiver clock management the receiver clock is generated from the transmitter clock or the divider clock or an external clock scanned on the rx_clock i/o pad. the rece ive clock is selected by the cks field in rcmr (receive clock mode register). receive clocks can be inverted independently by the cki bits in rcmr. the receiver can also drive the rx_clock i/o pad continuously or be limited to the actual data transfer. the clock output is configured by the rcmr register. the receive clock inversion (cki) bits have no effect on the clock outputs. programming the rcmr register to select rx_clock pin (cks field) and at the same time continuous receive clock (cko field) can lead to unpredi ctable results. tx_clock(pin) receiver clock divider clock cko data transfer tri-state controller inv mux cks mux tri-state controller cki ckg transmitter clock clock output
350 32054f?avr32?09/09 at32ap7002 figure 23-7. receiver clock management 23.7.1.4 serial clock ratio considerations the transmitter and the receiver can be programmed to operate with the clock signals provided on either the tx_clock or rx_clock pins. th is allows the ssc to support many slave-mode data transfers. in this case, the maximum clock speed allowed on the rx_clock pin is: ?master clock divided by 2 if receiver frame synchro is input ?master clock divided by 3 if receiver frame synchro is output in addition, the maximum clock spe ed allowed on the tx_clock pin is: ?master clock divided by 6 if transmit frame synchro is input ?master clock divided by 2 if transmit frame synchro is output 23.7.2 transmitter operations a transmitted frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured by setting the transmit clock mode register (tcmr). see section ?23.7.4? on page 352. the frame synchronization is configured setting the transmit frame mode register (tfmr). see section ?23.7.5? on page 354. to transmit data, the transmitter uses a shift re gister clocked by the transmitter clock signal and the start mode selected in the tcmr. data is written by the application to the thr register then transferred to the shift register according to the data format selected. when both the thr and the transmit shift register are empty, the status flag txempty is set in sr. when the transmit holding register is transferred in the transmit shift register, the status flag txrdy is set in sr and additional data can be loaded in the holding register. divider clock rx_clock (pin) transmitter clock mux tri-state controller cko data transfer inv mux cki tri-state controller ckg receiver clock clock output cks
351 32054f?avr32?09/09 at32ap7002 figure 23-8. transmitter block diagram 23.7.3 receiver operations a received frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured setting the receive clock mode register (rcmr). see section ?23.7.4? on page 352. the frame synchronization is configured setting the receive frame mode register (rfmr). see section ?23.7.5? on page 354. the receiver uses a shift register clocked by the receiver clock signal and the start mode selected in the rcmr. the data is transferred from the shift register depending on the data for- mat selected. when the receiver shift register is full, the ssc transfers this data in the holding register, the sta- tus flag rxrdy is set in sr and the data can be read in the receiver holding register. if another transfer occurs before read of the rhr register, the status flag overun is set in sr and the receiver shift register is tr ansferred in the rhr register. tfmr.datdef tfmr.msbf 0 1 transmit shift register 01 thr tshr tfmr.fslen tcmr.sttdly tfmr.fsden tfmr.datnb cr.txen cr.txdis sr.txen tx_data tfmr.datlen tcmr.sttdly tfmr.fsden start selector rx_frame_sync tx_frame_sync transmitter clock
352 32054f?avr32?09/09 at32ap7002 figure 23-9. receiver block diagram 23.7.4 start the transmitter and receiver can both be programmed to start their operations when an event occurs, respectively in the transmit start selection (start) field of tcmr and in the receive start selection (start) field of rcmr. under the following conditions the start event is independently programmable: ?continuous. in this case, the transmission starts as soon as a word is written in thr and the reception starts as soon as the receiver is enabled. ?synchronously with the transmitter/receiver ?on detection of a falling/rising edge on tx_frame_sync/rx_frame_sync ?on detection of a low level/high level on tx_frame_sync/rx_frame_sync ?on detection of a level change or an edge on tx_frame_sync/rx_frame_sync a start can be programmed in the same manner on either side of the transmit/receive clock register (rcmr/tcmr). thus, the start could be on tx_frame_sync (transmit) or rx_frame_sync (receive). moreover, the receiver can start when data is detected in the bit stream with the compare functions. detection on tx_frame_sync/rx_frame_sync input/output is done by the field fsos of the transmit/receive frame mode register (tfmr/rfmr). divider clock rx_clock (pin) transmitter clock mux tri-state controller cko data transfer inv mux cki tri-state controller ckg receiver clock clock output cks
353 32054f?avr32?09/09 at32ap7002 figure 23-10. transmit start mode figure 23-11. receive pulse/ed ge start modes xb0b1 b1 b0 b0 b1 b1 b0 b0 b1 b0 b1 b0 b1 b1 b0 x x x x x tx_data (output) start= any edge on tx_frame_sync tx_data (output) start= level change on tx_frame_sync tx_data (output) start= rising edge on tx_frame_sync tx_data (output) start= falling edge on tx_frame_sync tx_data (output) start= high level on tx_frame_sync tx_data (output) start= low level on tx_frame_sync tx_frame_sync (input) tx_clock (input) sttdly sttdly sttdly sttdly sttdly sttdly rx_clock rx_frame_sync (input) rx_data (input) start = high level on rx_frame_sync rx_data (input) start = falling edge on rx_frame_sync rx_data (input) start = rising edge on rx_frame_sync rx_data (input) start = level change on rx_frame_sync rx_data (input) start = any edge on rx_frame_sync rx_data (input) start = low level on rx_frame_sync x x x x x xb0 b0 b0 b0 b0 b0 b0 b1 b1 b1 b1 b1 b1 b1 sttdly sttdly sttdly sttdly sttdly sttdly
354 32054f?avr32?09/09 at32ap7002 23.7.5 frame sync the transmitter and receiver frame sync pins, tx_frame_syn c and rx_frame_sync, can be programmed to generate different kinds of frame synchronization signals. the frame sync output selection (fsos) field in the receive frame mode register (rfmr) and in the transmit frame mode register (tfmr) are used to select the required waveform. ?programmable low or high levels during data transfer are supported. ?programmable high levels before the start of data transfers or toggling are also supported. if a pulse waveform is selected, the frame sync length (fslen) field in rfmr and tfmr pro- grams the length of the pulse, from 1 bit time up to 16 bit time. the periodicity of the receive and transmit frame sync pulse output can be programmed through the period divider selection (period) field in rcmr and tcmr. 23.7.5.1 frame sync data frame sync data transmits or receives a specific tag during the frame sync signal. during the frame sync signal, the receiver can sample the rx_data line and store the data in the receive sync holding register and the tran smitter can transfer transmit sync holding reg- ister in the shifter register. the data length to be sampled/shifted out during the frame sync signal is programmed by the fslen field in rfmr/tfmr. concerning the receive frame sync data operation, if the frame sync length is equal to or lower than the delay between the start event and the actual data reception, the data sampling operation is performed in the re ceive sync holding register thr ough the receive shift register. the transmit frame sync operation is performed by the transmitter only if the bit frame sync data enable (fsden) in tfmr is set. if the fr ame sync length is equal to or lower than the delay between the start event and the actual dat a transmission, the normal transmission has pri- ority and the data contained in the transmit sync holding register is transferred in the transmit register, then shifted out. 23.7.5.2 frame sync edge detection the frame sync edge detection is programmed by the fsedge field in rfmr/tfmr. this sets the corresponding flags rxsyn/txsyn in the ssc status register (sr) on frame synchro edge detection (signals rx_frame_sync/tx_frame_sync).
355 32054f?avr32?09/09 at32ap7002 23.7.6 receive compare modes figure 23-12. receive compare modes 23.7.6.1 compare functions compare 0 can be one start event of the receiver. in this case, the receiver compares at each new sample the last fslen bits received at the fslen lower bit of the data contained in the compare 0 register (rc0r). when this start ev ent is selected, the user can program the receiver to start a new data transfer either by writing a new compare 0, or by receiving continu- ously until compare 1 occurs. this selecti on is done with the bit (stop) in rcmr. 23.7.7 data format the data framing format of both the transmitter and the receiver are programmable through the transmitter frame mode register (tfmr) and the receiver frame mode register (rfmr). in either case, the user can independently select: ?the event that starts the data transfer (start) ?the delay in number of bit periods between the start event and the first data bit ( sttdly ) ?the length of the data (datlen) ?the number of data to be transferred for each start event (datnb). ?the length of synchronization transferred for each start event (fslen) ?the bit sense: most or lowest significant bit first (msbf). additionally, the transmitter can be used to tr ansfer synchronization and select the level driven on the tx_data pin while not in data transfer operation. this is done respectively by the frame sync data enable (fsden) and by the data default value (datdef) bits in tfmr. rx_data (input) rx_clock cmp0 cmp1 cmp2 cmp3 start fslen up to 16 bits (4 in this example) sttdly ignored datlen b2 b0 b1
356 32054f?avr32?09/09 at32ap7002 figure 23-13. transmit and receive frame format in edge/pulse start modes note: 1. example of input on falling edge of tx_frame_sync/rx_frame_sync. table 23-3. data frame registers transmitter receiver field length comment tfmr rfmr datlen up to 32 size of word tfmr rfmr datnb up to 16 number of words transmitted in frame tfmr rfmr msbf most significant bit first tfmr rfmr fslen up to 16 size of synchro data register tfmr datdef 0 or 1 data default value ended tfmr fsden enable send tshr tcmr rcmr period up to 512 frame size tcmr rcmr sttdly up to 255 size of transmit start delay datnb datlen data data data data data data default default sync data sync data ignored from datdef start from datdef datlen to rhr to rhr from thr from thr from thr from thr from datdef from datdef ignored default default sync data to rshr from tshr fslen start tx_frame_sync / rx_frame_sync tx_data (if fsden = 1) tx_data (if fsden = 0) rx_data sttdly sync data period (1)
357 32054f?avr32?09/09 at32ap7002 figure 23-14. transmit frame format in continuous mode note: 1. sttdly is set to 0. in this example, thr is loaded twice. fsden value has no effect on the transmission. syncdata cannot be output in continuous mode. figure 23-15. receive frame format in continuous mode note: 1. sttdly is set to 0. 23.7.8 loop mode the receiver can be programmed to receive transmissions from the transmitter. this is done by setting the loop mode (loop) bit in rfmr. in this case, rx_data is connected to tx_data, rx_frame_sync is connected to tx_fra me_sync and rx_clock is connected to tx_clock. 23.7.9 interrupt most bits in sr have a corresponding bit in interrupt management registers. the ssc can be programmed to generate an interrupt when it detects an event. the interrupt is controlled by writing ier (interr upt enable register) and idr (int errupt disable register) these registers enable and disable, respectively, the corresponding interrupt by setting and clearing the corresponding bit in imr (interrupt mask register), which controls the generation of inter- rupts by asserting the ssc interrupt line connected to the interrupt controller. start data data datlen from thr datlen tx_data start: 1. txempty set to 1 2. write into the thr from thr default data data to rhr to rhr datlen datlen rx_data start = enable receiver
358 32054f?avr32?09/09 at32ap7002 figure 23-16. interrupt block diagram 23.8 ssc application examples the ssc can support several serial communica tion modes used in audio or high speed serial links. some standard applications are shown in t he following figures. all se rial link applications supported by the ssc are not listed here. figure 23-17. audio application block diagram imr ier idr clear set interrupt control ssc interrupt txrdy txempty txsync transmitter endtx txbufe pdca rxbuff endrx receiver rxrdy ovrun rxsync clock sck word select ws data sd msb left channel lsb msb right channel data sd word select ws clock sck ssc tx_clock tx_frame_sync tx_data rx_data rx_frame_sync rx_clock i2s receiver
359 32054f?avr32?09/09 at32ap7002 figure 23-18. codec application block diagram figure 23-19. time slot application block diagram ssc serial data clock (sclk) frame sync (fsync) serial data out serial data in serial data clock (sclk) frame sync (fsync) serial data out serial data in dstart dend first time slot codec tx_clock tx_frame_sync tx_data rx_data rx_frame_sync rx_clock codec first time slot codec second time slot data in data out fsync sclk serial data clock (sclk) frame sync (fsync) serial data out serial data in dstart first time slot second time slot dend ssc tx_clock tx_frame_sync tx_data rx_data rx_frame_sync rx_clock
360 32054f?avr32?09/09 at32ap7002 23.9 user interface table 23-4. register mapping offset register register name access reset 0x0 control register cr write ? 0x4 clock mode register cmr read/write 0x0 0x8 reserved ? ? ? 0xc reserved ? ? ? 0x10 receive clock mode register rcmr read/write 0x0 0x14 receive frame mode register rfmr read/write 0x0 0x18 transmit clock mode register tcmr read/write 0x0 0x1c transmit frame mode register tfmr read/write 0x0 0x20 receive holding register rhr read 0x0 0x24 transmit holding register thr write ? 0x28 reserved ? ? ? 0x2c reserved ? ? ? 0x30 receive sync. holding register rshr read 0x0 0x34 transmit sync. holding register tshr read/write 0x0 0x38 receive compare 0 register rc0r read/write 0x0 0x3c receive compare 1 register rc1r read/write 0x0 0x40 status register sr read 0x000000cc 0x44 interrupt enable register ier write ? 0x48 interrupt disable register idr write ? 0x4c interrupt mask register imr read 0x0 0x50-0xfc reserved ? ? ?
361 32054f?avr32?09/09 at32ap7002 23.9.1 control register name: cr access type: write-only offset: 0x00 reset value: - ? swrst: software reset 0: no effect. 1: performs a software reset. has priority on any other bit in cr. ? txdis: transmit disable 0: no effect. 1: disables transmit. if a character is currently being transmitted, disables at end of current character transmission. ? txen: transmit enable 0: no effect. 1: enables transmit if txdis is not set. ? rxdis: receive disable 0: no effect. 1: disables receive. if a character is currently being re ceived, disables at end of current character reception. ? rxen: receive enable 0: no effect. 1: enables receive if rxdis is not set. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 swrst?????txdistxen 76543210 ??????rxdisrxen
362 32054f?avr32?09/09 at32ap7002 23.9.2 clock mode register name: cmr access type: read/write offset: 0x04 reset value: 0x00000000 ? div: clock divider 0: the clock divider is not active. any other value: the divided clock equals the master clock di vided by 2 times div. the maximum bit rate is clk_ssc/2. the minimum bit rate is clk_ssc/2 x 4095 = clk_ssc/8190. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???? div 76543210 div
363 32054f?avr32?09/09 at32ap7002 23.9.3 receive clock mode register name: rcmr access type: read/write offset: 0x10 reset value: 0x00000000 ? period: receive period divider selection this field selects the divider to apply to the selected receive clock in order to generate a new frame sync signal. if 0, no period signal is generated. if not 0, a period sig nal is generated each 2 x (period+1) receive clock. ? sttdly: receive start delay if sttdly is not 0, a delay of sttdly clock cycles is inserted between the start event and the actual start of reception. when the receiver is programmed to start synchronously with the transmitter, the delay is also applied. note: it is very important that sttdly be set carefully. if sttdly must be set, it should be done in relation to tag (receive sync data) reception. ? stop: receive stop selection 0: after completion of a data transfer when starting with a compare 0, the receiver stops the data transfer and waits for a new compare 0. 1: after starting a receive with a compare 0, the receiver operates in a continuous mode until a compare 1 is detected. ? start: receive start selection 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 ? ? ? stop start 76543210 ckg cki cko cks start receive start 0x0 continuous, as soon as the receiver is enabled, and immediately after the end of transfer of the previous data. 0x1 transmit start 0x2 detection of a low level on rx_frame_sync signal 0x3 detection of a high level on rx_frame_sync signal 0x4 detection of a falling edge on rx_frame_sync signal 0x5 detection of a rising edge on rx_frame_sync signal 0x6 detection of any level change on rx_frame_sync signal 0x7 detection of any edge on rx_frame_sync signal 0x8 compare 0 0x9-0xf reserved
364 32054f?avr32?09/09 at32ap7002 ? ckg: receive clock gating selection ? cki: receive clock inversion 0: the data inputs (data and frame sync signals) are sample d on receive clock falling edge . the frame sync signal out- put is shifted out on receive clock rising edge. 1: the data inputs (data and frame sync signals) are sample d on receive clock rising edge. the frame sync signal out- put is shifted out on receive clock falling edge. cki affects only the receive clock and not the output clock signal. ? cko: receive clock output mode selection ? cks: receive clock selection ckg receive clock gating 0x0 none, continuous clock 0x1 receive clock enabled only if rx_frame_sync low 0x2 receive clock enabled only if rx_frame_sync high 0x3 reserved cko receive clock outp ut mode rx_clock pin 0x0 none input-only 0x1 continuous receive clock output 0x2 receive clock only during data transfers output 0x3-0x7 reserved cks selected receive clock 0x0 divided clock 0x1 tx_clock clock signal 0x2 rx_clock pin 0x3 reserved
365 32054f?avr32?09/09 at32ap7002 23.9.4 receive frame mode register name: rfmr access type: read/write offset: 0x14 reset value: 0x00000000 ? fslenhi: receive frame sync length high part the four msb of the fslen bitfield. ? fsedge: frame sync edge detection determines which edge on frame sy nc will generate the in terrupt rxsyn in the ssc status register. ? fsos: receive frame sync output selection ? fslen: receive frame sync length this field defines the length of the receive frame sync signal and the number of bits sampled and stored in the receive sync data register. when this mode is selected by the start field in the receive clock mode register, it also deter- mines the length of the sampled data to be compared to the compare 0 or compare 1 register. note: the four most significant bits fo this bitfield are in the fslenhi bitfield. pulse length is equal to ({fslenhi,fslen} + 1) receive clock periods. thus, if {fslenhi,fslen} is 0, the receive frame sync signal is generated during one receive clock period. ? datnb: data number per frame 31 30 29 28 27 26 25 24 fslenhi ???fsedge 23 22 21 20 19 18 17 16 ? fsos fslen 15 14 13 12 11 10 9 8 ???? datnb 76543210 msbf ? loop datlen fsedge frame sync edge detection 0x0 positive edge detection 0x1 negative edge detection fsos selected receive frame sy nc signal rx_f rame_sync pin 0x0 none input-only 0x1 negative pulse output 0x2 positive pulse output 0x3 driven low during data transfer output 0x4 driven high during data transfer output 0x5 toggling at each start of data transfer output 0x6-0x7 reserved undefined
366 32054f?avr32?09/09 at32ap7002 this field defines the number of data words to be received after each transfer start, which is equal to (datnb + 1). ? msbf: most significant bit first 0: the lowest significant bit of the data register is sampled first in the bit stream. 1: the most significant bit of the data register is sampled first in the bit stream. ? loop: loop mode 0: normal operating mode. 1: rx_data is driven by tx_data, rx_frame_sync is driven by tx_frame_sync and tx_clock drives rx_clock. ? datlen: data length 0: forbidden value (1-bit data length not supported). any other value: the bit stream contains datlen + 1 data bits. moreover, it defines the transfer size performed by the pdca assigned to the receiver. if datlen is lower or equal to 7, data transfers are in bytes. if datlen is between 8 and 15 (included), half-words are transferred, and for any other value, 32-bit words are transferred.
367 32054f?avr32?09/09 at32ap7002 23.9.5 transmit clock mode register name: tcmr access type: read/write offset: 0x18 reset value: 0x00000000 ? period: transmit period divider selection this field selects the divider to apply to the selected transmi t clock to generate a new frame sync signal. if 0, no period signal is generated. if not 0, a period signal is generated at each 2 x (period+1) transmit clock. ? sttdly: transmit start delay if sttdly is not 0, a delay of sttdly clock cycles is inse rted between the start event and the actual start of transmission of data. when the transmitter is programmed to start sync hronously with the receiver, the delay is also applied. note: sttdly must be set carefully. if sttdly is too short in respect to tag (transmit sync data) emission, data is emit- ted instead of the end of tag. ? start: transmit start selection 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 ???? start 76543210 ckg cki cko cks start transmit start 0x0 continuous, as soon as a word is written in the thr register (if transmit is enabled), and immediately after the end of transfer of the previous data. 0x1 receive start 0x2 detection of a low level on tx_frame_sync signal 0x3 detection of a high level on tx_frame_sync signal 0x4 detection of a falling edge on tx_frame_sync signal 0x5 detection of a rising edge on tx_frame_sync signal 0x6 detection of any level change on tx_frame_sync signal 0x7 detection of any edge on tx_frame_sync signal 0x8 - 0xf reserved
368 32054f?avr32?09/09 at32ap7002 ? ckg: transmit clock gating selection ? cki: transmit clock inversion 0: the data outpu ts (data and frame sync signals) are shifted out on tr ansmit clock falling edge . the frame sync signal input is sampled on transmit clock rising edge. 1: the data outputs (data and frame sync signals) are shifted out on transmit clock rising edge. the frame sync signal input is sampled on tran smit clock falling edge. cki affects only the transmit clock and not the output clock signal. ? cko: transmit clock output mode selection ? cks: transmit clock selection ckg transmit clock gating 0x0 none, continuous clock 0x1 transmit clock enabled only if tx_frame_sync low 0x2 transmit clock enabled only if tx_frame_sync high 0x3 reserved cko transmit clock output mode tx_clock pin 0x0 none input-only 0x1 continuous transmit clock output 0x2 transmit clock only during data transfers output 0x3-0x7 reserved cks selected transmit clock 0x0 divided clock 0x1 rx_clock clock signal 0x2 tx_clock pin 0x3 reserved
369 32054f?avr32?09/09 at32ap7002 23.9.6 transmit frame mode register name: tfmr access type: read/write offset: 0x1c reset value: 0x00000000 ? fslenhi: transmit frame sync length high part the four msb of the fslen bitfield. ? fsedge: frame sync edge detection determines which edge on frame sync will gene rate the interrupt tx syn (status register). ? fsden: frame sync data enable 0: the tx_data line is driven with the defaul t value during the transmit frame sync signal. 1: tshr value is shifted out during the tran smission of the transmi t frame sync signal. ? fsos: transmit frame sync output selection ? fslen: transmit frame sync length this field defines the length of the transmit frame sync sig nal and the number of bits shifted out from the transmit sync data register if fsden is 1. note: the four most significant bits fo this bitfield are in the fslenhi bitfield. 31 30 29 28 27 26 25 24 fslenhi ???fsedge 23 22 21 20 19 18 17 16 fsden fsos fslen 15 14 13 12 11 10 9 8 ???? datnb 76543210 m s b f ? dat d e f dat l e n fsedge frame sync edge detection 0x0 positive edge detection 0x1 negative edge detection fsos selected transmit frame sync signal tx_frame_sync pin 0x0 none input-only 0x1 negative pulse output 0x2 positive pulse output 0x3 driven low during data transfer output 0x4 driven high during data transfer output 0x5 toggling at each start of data transfer output 0x6-0x7 reserved undefined
370 32054f?avr32?09/09 at32ap7002 pulse length is equal to ({fslenhi,fslen} + 1) transmit clock periods, i.e., the pulse length can range from 1 to 16 transmit clock periods. if {fslenhi,fslen} is 0, the transmi t frame sync signal is generated during one transmit clock period. ? datnb: data number per frame this field defines the number of data words to be transferred after each transfer start, which is equal to (datnb +1). ? msbf: most significant bit first 0: the lowest significant bit of the data register is shifted out first in the bit stream. 1: the most significant bit of the data register is shifted out first in the bit stream. ? datdef: data default value this bit defines the level driven on the tx_data pin while out of transmission. note that if th e pin is defined as multi-drive by the pio controller, the pin is enabled only if the scc tx_data output is 1. ? datlen: data length 0: forbidden value (1-bit data length not supported). any other value: the bit stream contains datlen + 1 data bits. moreover, it defines the transfer size performed by the pdca assigned to the transmit. if datlen is lower or equal to 7, data transfers are bytes, if datlen is between 8 and 15 (included), half-words are transferred, and for any other value, 32-bit words are transferred.
371 32054f?avr32?09/09 at32ap7002 23.9.7 ssc receive holding register name: rhr access type: read-only offset: 0x20 reset value: 0x00000000 ? rdat: receive data right aligned regardless of the number of data bits defined by datlen in rfmr. 31 30 29 28 27 26 25 24 rdat 23 22 21 20 19 18 17 16 rdat 15 14 13 12 11 10 9 8 rdat 76543210 rdat
372 32054f?avr32?09/09 at32ap7002 23.9.8 transmit holding register name: thr access type: write-only offset: 0x24 reset value: - ? tdat: transmit data right aligned regardless of the number of data bits defined by datlen in tfmr. 31 30 29 28 27 26 25 24 tdat 23 22 21 20 19 18 17 16 tdat 15 14 13 12 11 10 9 8 tdat 76543210 tdat
373 32054f?avr32?09/09 at32ap7002 23.9.9 receive synchronization holding register name: rshr access type: read-only offset: 0x30 reset value: 0x00000000 ? rsdat: receive synchronization data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rsdat 76543210 rsdat
374 32054f?avr32?09/09 at32ap7002 23.9.10 transmit synchronization holding register name: tshr access type: read/write offset: 0x34 reset value: 0x00000000 ? tsdat: transmit synchronization data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 tsdat 76543210 tsdat
375 32054f?avr32?09/09 at32ap7002 23.9.11 receive compare 0 register name: rc0r access type: read/write offset: 0x38 reset value: 0x00000000 ? cp0: receive compare data 0 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cp0 76543210 cp0
376 32054f?avr32?09/09 at32ap7002 23.9.12 receive compare 1 register name: rc1r access type: read/write offset: 0x3c reset value: 0x00000000 ? cp1: receive compare data 1 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cp1 76543210 cp1
377 32054f?avr32?09/09 at32ap7002 23.9.13 status register name: sr access type: read-only offset: 0x40 reset value: 0x000000cc ? rxen: receive enable 0: receive is disabled. 1: receive is enabled. ? txen: transmit enable 0: transmit is disabled. 1: transmit is enabled. ? rxsyn: receive sync 0: an rx sync has not occurred since the last read of the status register. 1: an rx sync has occurred since the last read of the status register. ? txsyn: transmit sync 0: a tx sync has not occurred since the last read of the status register. 1: a tx sync has occurred since the last read of the status register. ?cp1: compare 1 0: a compare 1 has not occurred since the last read of the status register. 1: a compare 1 has occurred since the last read of the status register. ?cp0: compare 0 0: a compare 0 has not occurred since the last read of the status register. 1: a compare 0 has occurred since the last read of the status register. ? rxbuff: receive buffer full 0: rcr or rncr have a value other than 0. 1: both rcr and rncr have a value of 0. ? endrx: end of reception 0: data is written on the receive counter register or receive ne xt counter register. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ??????rxentxen 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
378 32054f?avr32?09/09 at32ap7002 1: end of pdca transfer when receive counter register has arrived at zero. ? ovrun: receive overrun 0: no data has been loaded in rhr while previous data has not been read since the last read of the status register. 1: data has been loaded in rhr while previous data has not yet been read since the last read of the status register. ? rxrdy: receive ready 0: rhr is empty. 1: data has been received and loaded in rhr. ? txbufe: transmit buffer empty 0: tcr or tncr have a value other than 0. 1: both tcr and tncr have a value of 0. ? endtx: end of transmission 0: the register tcr has not reached 0 since the last write in tcr or tncr. 1: the register tcr has reached 0 since the last write in tcr or tncr. ? txempty: transmit empty 0: data remains in thr or is currently transmitted from tsr. 1: last data written in thr has been loaded in tsr and last data loaded in tsr has been transmitted. ? txrdy: transmit ready 0: data has been loaded in thr and is waiting to be loaded in the transmit shift register (tsr). 1: thr is empty.
379 32054f?avr32?09/09 at32ap7002 23.9.14 interrupt enable register name: ier access type: write-only offset: 0x44 reset value: - ? rxsyn: rx sync interrupt enable 0: no effect. 1: enables the rx sync interrupt. ? txsyn: tx sync interrupt enable 0: no effect. 1: enables the tx sync interrupt. ? cp1: compare 1 interrupt enable 0: no effect. 1: enables the compare 1 interrupt. ? cp0: compare 0 interrupt enable 0: no effect. 1: enables the compare 0 interrupt. ? rxbuff: receive buffer full interrupt enable 0: no effect. 1: enables the receive buffer full interrupt. ? endrx: end of reception interrupt enable 0: no effect. 1: enables the end of reception interrupt. ? ovrun: receive overrun interrupt enable 0: no effect. 1: enables the receive overrun interrupt. ? rxrdy: receive ready interrupt enable 0: no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
380 32054f?avr32?09/09 at32ap7002 1: enables the receive ready interrupt. ? txbufe: transmit buffer empty interrupt enable 0: no effect. 1: enables the transmit buffer empty interrupt ? endtx: end of transmission interrupt enable 0: no effect. 1: enables the end of transmission interrupt. ? txempty: transmit empty interrupt enable 0: no effect. 1: enables the transmit empty interrupt. ? txrdy: transmit ready interrupt enable 0: no effect. 1: enables the transmit ready interrupt.
381 32054f?avr32?09/09 at32ap7002 23.9.15 interrupt disable register name: idr access type: write-only offset: 0x48 reset value: - ? rxsyn: rx sync interrupt enable 0: no effect. 1: disables the rx sync interrupt. ? txsyn: tx sync interrupt enable 0: no effect. 1: disables the tx sync interrupt. ? cp1: compare 1 interrupt disable 0: no effect. 1: disables the compare 1 interrupt. ? cp0: compare 0 interrupt disable 0: no effect. 1: disables the compare 0 interrupt. ? rxbuff: receive buffer full interrupt disable 0: no effect. 1: disables the receiv e buffer full interrupt. ? endrx: end of reception interrupt disable 0: no effect. 1: disables the end of reception interrupt. ? ovrun: receive overrun interrupt disable 0: no effect. 1: disables the receive overrun interrupt. ? rxrdy: receive ready interrupt disable 0: no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
382 32054f?avr32?09/09 at32ap7002 1: disables the rece ive ready interrupt. ? txbufe: transmit buffer empty interrupt disable 0: no effect. 1: disables the transmit buffer empty interrupt. ? endtx: end of transmission interrupt disable 0: no effect. 1: disables the end of transmission interrupt. ? txempty: transmit empty interrupt disable 0: no effect. 1: disables the transmit empty interrupt. ? txrdy: transmit ready interrupt disable 0: no effect. 1: disables the transmit ready interrupt.
383 32054f?avr32?09/09 at32ap7002 23.9.16 interrupt mask register name: imr access type: read-only offset: 0x4c reset value: 0x00000000 ? rxsyn: rx sync interrupt mask 0: the rx sync interrupt is disabled. 1: the rx sync interrupt is enabled. ? txsyn: tx sync interrupt mask 0: the tx sync interrupt is disabled. 1: the tx sync interrupt is enabled. ? cp1: compare 1 interrupt mask 0: the compare 1 interrupt is disabled. 1: the compare 1 interrupt is enabled. ? cp0: compare 0 interrupt mask 0: the compare 0 interrupt is disabled. 1: the compare 0 interrupt is enabled. ? rxbuff: receive buffer full interrupt mask 0: the receive buffer full interrupt is disabled. 1: the receive buffer full interrupt is enabled. ? endrx: end of reception interrupt mask 0: the end of reception interrupt is disabled. 1: the end of reception interrupt is enabled. ? ovrun: receive overrun interrupt mask 0: the receive overrun interrupt is disabled. 1: the receive overrun interrupt is enabled. ? rxrdy: receive ready interrupt mask 0: the receive ready interrupt is disabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
384 32054f?avr32?09/09 at32ap7002 24. universal synchronous/asynchro nous receiver/transmitter (usart) rev: 3.0.2.3 24.1 features ? programmable baud rate generator ? 5- to 9-bit full-duplex synchronous or asynchronous serial communications ? 1, 1.5 or 2 stop bits in asynchronous mode or 1 or 2 stop bits in synchronous mode ? parity generation and error detection ? framing error detection, overrun error detection ? msb- or lsb-first ? optional break generation and detection ? by 8 or by 16 over-sampling receiver frequency ? optional hardware handshaking rts-cts ? receiver time-out and transmitter timeguard ? optional multidrop mode with address generation and detection ? rs485 with driver control signal ? iso7816, t = 0 or t = 1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit ? irda modulation and demodulation ? communication at up to 115.2 kbps ? test modes ? remote loopback, local loopback, automatic echo ? supports connection of two peripheral dma controller channels (pdc) ? offers buffer transfer wi thout processor intervention 24.2 overview the universal synchronous asynchronous rece iver transceiver (usart) provides one full duplex universal synchronous asynchronous serial link. data frame format is widely programma- ble (data length, parity, number of stop bits) to support a maximum of standards. the receiver implements parity error, framing error and overrun error detection. the receiver time-out enables handling variable-length frames and the transmitt er timeguard facilitates communications with slow remote devices. multidrop communications are also supported through address bit han- dling in reception and transmission. the usart features three test modes: remote loopback, local loopback and automatic echo. the usart supports specific operating modes providing interfaces on rs485 buses, with iso7816 t = 0 or t = 1 smart card slots and infrared transceivers. the hardware handshaking feature enables an out-of-band flow control by automatic management of the pins rts and cts. the usart supports the connection to the peripheral dma controller, which enables data transfers to the transmitter and from the receiver. the pdc provides chained buffer manage- ment without any intervention of the processor.
385 32054f?avr32?09/09 at32ap7002 24.3 block diagram figure 24-1. usart block diagram peripheral dma controller channel channel intc power manager div receiver transmitter user interface pio controller rxd rts txd cts clk baudrate generator usart interrupt clk_usart clk_usart/div usart peripheral bus
386 32054f?avr32?09/09 at32ap7002 24.4 application block diagram figure 24-2. application block diagram 24.5 i/o lines description table 24-1. i/o line description name description type active level clk serial clock i/o txd transmit serial data i/o rxd receive serial data input cts clear to send input low rts request to send output low smart card slot usart rs485 drivers differential bus irda transceivers field bus driver emv driver irda driver irlap rs232 drivers serial port serial driver ppp
387 32054f?avr32?09/09 at32ap7002 24.6 product dependencies 24.6.1 i/o lines the pins used for interfacing the usart may be multiplexed with the pio lines. the program- mer must first program the pio controller to assign the desired usart pins to their peripheral function. if i/o lines of the usart are not used by the application, they can be used for other purposes by the pio controller. to prevent the txd line from falling when the usart is di sabled, the use of an internal pull up is mandatory. 24.6.2 power manager (pm) the usart is not continuously clocked. the programmer must ensure that the usart clock is enabled in the power manager (pm) before using the usart. however, if the application does not require usart operations, the usart clock can be stopped when not needed and be restarted later. in this case, the usart will resu me its operations where it left off. usart clock (clk_usart) in the usart description is the cl ock for the peripheral bus to which the usart is connected. 24.6.3 interrupt the usart interrupt line is connected on one of the internal sources of the interrupt controller. using the usart interrupt requires the interrupt controller to be programmed first.
388 32054f?avr32?09/09 at32ap7002 24.7 functional description the usart is capable of managing several ty pes of serial synchronous or asynchronous communications. it supports the following communication modes: ?5- to 9-bit full-duplex asynchronous serial communication ?msb- or lsb-first ?1, 1.5 or 2 stop bits ?parity even, odd, marked, space or none ?by 8 or by 16 over-sampling receiver frequency ?optional hardware handshaking ?optional break management ?optional multidrop serial communication ?high-speed 5- to 9-bit full-duplex synchronous serial communication ?msb- or lsb-first ?1 or 2 stop bits ?parity even, odd, marked, space or none ?by 8 or by 16 over-sampling frequency ?optional hardware handshaking ?optional break management ?optional multidrop serial communication ?rs485 with driver control signal ?iso7816, t0 or t1 protocols for interfacing with smart cards ?nack handling, error counter with repetition and iteration limit ?infrared irda modulation and demodulation ?test modes ?remote loopback, local loopback, automatic echo 24.7.1 baud rate generator the baud rate generator provides the bit period clock named the baud rate clock to both the receiver and the transmitter. the baud rate generator clock source can be selected by setting the usclks field in the mode register (mr) between: ?the clk_usart ?a division of the clk_usart, the divider being product dependent, but generally set to 8 ?the external clock, available on the clk pin the baud rate generator is based upon a 16-bit divider, which is programmed with the cd field of the baud rate generator register (brgr). if cd is programmed at 0, the baud rate gener- ator does not generate any clock. if cd is programmed at 1, the divider is bypassed and becomes inactive.
389 32054f?avr32?09/09 at32ap7002 if the external clk clock is selected, the duration of the low and high levels of the signal pro- vided on the clk pin must be longer than a clk_usart period. the frequency of the signal provided on clk must be at least 4.5 times lower than clk_usart. figure 24-3. baud rate generator 24.7.1.1 baud rate in asynchronous mode if the usart is programmed to operate in as ynchronous mode, the selected clock is first divided by cd, which is field programmed in the baud rate generator register (brgr). the resulting clock is provided to the receiver as a sampling clock and then divided by 16 or 8, depending on the programming of the over bit in mr. if over is set to 1, the receiver sampling is 8 times higher than the baud rate clock. if over is cleared, the sampling is performed at 16 times the baud rate clock. the following formula performs the calculation of the baud rate. this gives a maximum baud rate of clk_usar t divided by 8, assuming that clk_usart is the highest possible clock and that over is programmed at 1. 24.7.1.2 baud rate calculation example table 24-2 shows calculations of cd to obtain a baud rate at 38400 bauds for different source clock frequencies. this table also shows the actual resulting baud rate and the error. 16-bit counter cd usclks cd clk_usart clk_usart/div reserved clk sync sync usclks= 3 fidi over sampling divider baudrate clock sampling clock 1 0 0 clk 0 1 2 3 >1 1 1 0 0 baudrate selectedclock 82 over ? () cd () -------------------------------------------- = table 24-2. baud rate example (over = 0) source clock expected baud rate calculation result cd actual baud rate error mhz bit/s bit/s 3 686 400 38 400 6.00 6 38 400.00 0.00% 4 915 200 38 400 8.00 8 38 400.00 0.00% 5 000 000 38 400 8.14 8 39 062.50 1.70%
390 32054f?avr32?09/09 at32ap7002 the baud rate is calculated with the following formula: the baud rate error is calculated with the following formula. it is not recommended to work with an error higher than 5%. 24.7.1.3 fractional baud rate in asynchronous mode the baud rate generator previously defined is su bject to the following limitation: the output fre- quency changes by only integer multiples of the reference frequency. an approach to this problem is to integrate a fractional n clock generator that has a high resolution. the generator architecture is modified to obtain baud rate c hanges by a fraction of the reference source clock. this fractional part is programmed with the fp field in the baud rate generator register (brgr). if fp is not 0, the fractional part is acti vated. the resolution is one eighth of the clock divider. this feature is only available when using usart normal mode. the fractional baud rate is calculated using the following formula: 7 372 800 38 400 12.00 12 38 400.00 0.00% 8 000 000 38 400 13.02 13 38 461.54 0.16% 12 000 000 38 400 19.53 20 37 500.00 2.40% 12 288 000 38 400 20.00 20 38 400.00 0.00% 14 318 180 38 400 23.30 23 38 908.10 1.31% 14 745 600 38 400 24.00 24 38 400.00 0.00% 18 432 000 38 400 30.00 30 38 400.00 0.00% 24 000 000 38 400 39.06 39 38 461.54 0.16% 24 576 000 38 400 40.00 40 38 400.00 0.00% 25 000 000 38 400 40.69 40 38 109.76 0.76% 32 000 000 38 400 52.08 52 38 461.54 0.16% 32 768 000 38 400 53.33 53 38 641.51 0.63% 33 000 000 38 400 53.71 54 38 194.44 0.54% 40 000 000 38 400 65.10 65 38 461.54 0.16% 50 000 000 38 400 81.38 81 38 580.25 0.47% 60 000 000 38 400 97.66 98 38 265.31 0.35% 70 000 000 38 400 113.93 114 38 377.19 0.06% table 24-2. baud rate example (over = 0) (continued) source clock expected baud rate calculation result cd actual baud rate error baudrate clkusart () cd 16 ? = error 1 expectedbaudrate actualbaudrate -------------------------------------------------- - ?? ?? ? = baudrate selectedclock 82 over ? () cd fp 8 ------- + ?? ?? ?? ?? ---------------------------------------------------------------- - =
391 32054f?avr32?09/09 at32ap7002 the modified architecture is presented below: figure 24-4. fractional baud rate generator 24.7.1.4 baud rate in synchronous mode if the usart is programmed to operate in synchronous mode, the selected clock is simply divided by the field cd in brgr. in synchronous mode, if the external clock is selected (usclks = 3), the clock is provided directly by the signal on the usart clk pin. no division is active. the value written in brgr has no effect. the external clock frequency must be at least 4.5 times lower than the system clock. when either the external clock clk or the inte rnal clock divided (clk_usart/div) is selected, the value programmed in cd must be even if the user has to ensure a 50:50 mark/space ratio on the clk pin. if the internal clock clk_usart is selected, the baud rate generator ensures a 50:50 duty cycle on the clk pin, even if the value programmed in cd is odd. 24.7.1.5 baud rate in iso 7816 mode the iso7816 specification defines the bit rate with the following formula: where: ?b is the bit rate ?di is the bit-rate adjustment factor ?fi is the clock frequency division factor ?f is the iso7816 clock frequency (hz) usclks cd modulus control fp fp cd glitch-free logic 16-bit counter over fidi sync sampling divider clk_usart clk_usart/div reserved clk clk baudrate clock sampling clock sync usclks = 3 >1 1 2 3 0 0 1 0 1 1 0 0 baudrate selectedclock cd ------------------------------------- - = b di fi ----- - f =
392 32054f?avr32?09/09 at32ap7002 di is a binary value encoded on a 4-bit field, named di, as represented in table 24-3 . fi is a binary value encoded on a 4-bi t field, named fi, as represented in table 24-4 . table 24-5 shows the resulting fi/di ratio, which is the ratio between the iso7816 clock and the baud rate clock. if the usart is configured in iso7816 mode, th e clock selected by the usclks field in the mode register (mr) is first divided by the valu e programmed in the field cd in the baud rate generator register (brgr). the resulting clock can be provided to the clk pin to feed the smart card clock inputs. this means that the clko bit can be set in mr. this clock is then divided by the value progra mmed in the fi_di_ratio field in the fi_di_ratio register (fidi). this is performed by the sampling divider, which performs a division by up to 2047 in iso7816 mode. the non-integer values of the fi/di ratio are not supported and the user must program the fi_di_ratio field to a value as close as possible to the expected value. the fi_di_ratio field resets to the value 0x174 (372 in decimal) and is the most common divider between the iso7816 clock and the bit rate (fi = 372, di = 1). figure 24-5 shows the relation between the elementary time unit, corresponding to a bit time, and the iso 7816 clock. table 24-3. binary and decimal values for di di field 0001 0010 0011 0100 0101 0110 1000 1001 di (decimal)1 2 4 8 163212 20 table 24-4. binary and decimal values for fi fi field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101 fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048 table 24-5. possible values for the fi/di ratio fi/di 372 558 774 1116 1488 1806 512 768 1024 1536 2048 1 372 558 744 1116 1488 1860 512 768 1024 1536 2048 2 186 279 372 558 744 930 256 384 512 768 1024 4 93 139.5 186 279 372 465 128 192 256 384 512 8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256 16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128 32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64 12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6 20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4
393 32054f?avr32?09/09 at32ap7002 figure 24-5. elementary time unit (etu) 24.7.2 receiver and transmitter control after reset, the receiver is disabled. the user must enable the receiver by setting the rxen bit in the control register (cr). however, the receiver registers can be programmed before the receiver clock is enabled. after reset, the transmitter is disabled. the user must enable it by setting the txen bit in the control register (cr). however, the transmitter registers can be programmed before being enabled. the receiver and the transmitter can be enabled together or independently. at any time, the software can perform a reset on the receiver or the transmitter of the usart by setting the corresponding bit, rstrx and rsttx re spectively, in the control register (cr). the reset commands have the same effect as a hardware reset on the corresponding logic. regardless of what the receiver or the transmi tter is performing, the communication is immedi- ately stopped. the user can also independently disable the receiv er or the transmitter by setting rxdis and txdis respectively in cr. if the receiver is disabled during a character reception, the usart waits until the end of reception of the current character, then the reception is stopped. if the transmitter is disabled while it is operating, the usart waits the end of transmission of both the current character and character being stored in the transmit holding register (thr). if a time- guard is programmed, it is handled normally. 24.7.3 synchronous and asynchronous modes 24.7.3.1 transmitter operations the transmitter performs the same in both synchronous and asynchronous operating modes (sync = 0 or sync = 1). one start bit, up to 9 da ta bits, one optional parity bit and up to two stop bits are successively shifted out on the txd pin at each falling edge of the programmed serial clock. the number of data bits is selected by the chrl field and the mode 9 bit in the mode register (mr). nine bits are selected by setting the mode 9 bit regardless of the chrl field. the parity bit is set according to the par field in mr. the even, odd, space, marked or none parity bit can be configured. the msbf field in mr configures wh ich data bit is sent first. if written at 1, the most significant bit is sent first. at 0, the less signi ficant bit is sent first. the number of stop bits is selected by the nbstop field in mr. the 1.5 stop bit is supported in asynchronous mode only. 1 etu fi_di_ratio iso7816 clock cycles so7816 clock on clk o7816 i/o line on txd
394 32054f?avr32?09/09 at32ap7002 figure 24-6. character transmit the characters are sent by writing in the tr ansmit holding register (thr). the transmitter reports two status bits in the channel status register (csr): txrdy (transmitter ready), which indicates that thr is empt y and txempty, which indicates that all the characters written in thr have been processed. when the current character processing is completed, the last character written in thr is transferred into the shift register of the transmitter and thr becomes empty, thus txrdy raises. both txrdy and txempty bits are low since the transmitter is disabled. writing a character in thr while txrdy is active has no effect and the written character is lost. figure 24-7. transmitter status 24.7.3.2 manchester encoder when the manchester encoder is in use, c haracters transmitted through the usart are encoded based on biphase manchester ii format. to enable this mode, set the man field in the mr register to 1. depending on polarity configurat ion, a logic level (zero or one), is transmitted as a coded signal one-to-zero or zero-to-one. thus, a transition always occurs at the midpoint of each bit time. it consumes more bandwidth than the original nrz signal (2x) but the receiver has more error control since the expected input must show a change at the center of a bit cell. an example of manchester encoded sequence is: th e byte 0xb1 or 10110001 encodes to 10 01 10 10 01 01 01 10, assuming the default polarity of the encoder. figure 24-8 illustrates this coding scheme. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit example: 8-bit, parity enabled one stop baud rate clock d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit write us_thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty
395 32054f?avr32?09/09 at32ap7002 figure 24-8. nrz to manchester encoding the manchester encoded character can also be enc apsulated by adding both a configurable preamble and a start frame delimiter pattern. depending on the configuration, the preamble is a training sequence, composed of a pre-defined pattern with a programmable length from 1 to 15 bit times. if the preamble length is set to 0, the preamble waveform is not generated prior to any character. the preamble pattern is chosen among the following sequences: all_one, all_zero, one_zero or zero_one, writing the field tx_pp in the man register, the field tx_pl is used to configure the preamble length. figure 24-9 illustrates and defines the valid patterns. to improve flexibility, the encodi ng scheme can be configured using the tx_mpol field in the man register. if the tx_mpol field is set to zero (default), a logic zero is encoded with a zero-to-one transition and a logic one is encoded with a one-to-zero transition. if the tx_mpol field is set to one, a logic one is encoded with a one-to-zero transition and a logic zero is encoded with a zero-to-one transition. figure 24-9. preamble patterns, default polarity assumed a start frame delimiter is to be configured using the onebit field in the mr register. it consists of a user-defined pattern that indicates the beginning of a valid data. figure 24-10 illustrates these patterns. if the start frame delimiter, also known as start bit, is one bit, (onebit at 1), a logic zero is manchester encoded and indicates that a new character is being sent serially on the line. if the start frame delimiter is a synchronization pattern also referred to as sync (onebit at 0), a sequence of 3 bit times is sent serially on the line to indicate the start of a new character. nrz encoded data manchester encoded data 10110001 txd manchester encoded data txd sfd data 8 bit width "all_one" preamble manchester encoded data txd sfd data 8 bit width "all_zero" preamble manchester encoded data txd sfd data 8 bit width "zero_one" preamble manchester encoded data txd sfd data 8 bit width "one_zero" preamble
396 32054f?avr32?09/09 at32ap7002 the sync waveform is in itself an invalid manchester waveform as the transition occurs at the middle of the second bit time. two distinct sync patterns are used: the command sync and the data sync. the command sync has a logic one level for one and a half bit times, then a transition to logic zero for the second one and a half bit times. if the modsync field in the mr register is set to 1, the next character is a command. if it is set to 0, the next character is a data. when direct memory access is used, the modsync field can be immediately updated with a modified character located in memory. to enable this mode, var_sync field in mr register must be set to 1. in this case, the modsync field in mr is bypassed and the sync configuration is held in the txsynh in the thr register. the usart character format is modified and includes sync information. figure 24-10. start frame delimiter 24.7.3.3 drift compensation drift compensation is available only in 16x oversampling mode. an ha rdware recovery system allows a larger clock drift. to enable the hardwa re system, the bit in th e man register must be set. if the rxd edge is one 16x clock cycle from the expected edge, this is considered as nor- mal jitter and no corrective actions is taken. if the rxd event is between 4 and 2 clock cycles before the expected edge, then the current period is shortened by one clock cycle. if the rxd event is between 2 and 3 clock cycles after the expected edge, then the current period is length- ened by one clock cycle. these intervals are considered to be drift and so corrective actions are automatically taken. manchester encoded data txd sfd data one bit start frame delimiter preamble length is set to 0 manchester encoded data txd sfd data command sync start frame delimiter manchester encoded data txd sfd data data sync start frame delimiter
397 32054f?avr32?09/09 at32ap7002 figure 24-11. bit resynchronization 24.7.3.4 asynchronous receiver if the usart is programmed in asynchronous operating mode (sync = 0), the receiver over- samples the rxd input line. the oversampling is either 16 or 8 times the baud rate clock, depending on the over bit in the mode register (mr). the receiver samples the rxd line. if the line is sampled during one half of a bit time at 0, a start bit is detected and data, parity and stop bits are successively sampled on the bit rate clock. if the oversampling is 16, (over at 0), a start is detected at the eighth sample at 0. then, data bits, parity bit and stop bit are sampled on each 16 sampling clock cycle. if the oversampling is 8 (over at 1), a start bit is detected at the fourth sample at 0. then, data bits, parity bit and stop bit are sampled on each 8 sampling clock cycle. the number of data bits, first bit sent and parity mode are selected by the same fields and bits as the transmitter, i.e. respectively chrl, mo de9, msbf and par. the number of stop bits has no effect on the receiver as it considers only one stop bit, regardless of the field nbstop, so that resynchronization between the receiv er and the transmitter can occur. moreover, as soon as the stop bit is sampled, the receiver starts looking for a new start bit so that resynchroni- zation can also be accomplished when the transmitter is operating with one stop bit. figure 24-12 and figure 24-13 illustrate start detection and character reception when usart operates in asynchronous mode. rxd oversampling 16x clock sampling point expected edge tolerance synchro. jump sync jump synchro. error synchro. error
398 32054f?avr32?09/09 at32ap7002 figure 24-12. asynchronous start detection figure 24-13. asynchronous character reception 24.7.3.5 manchester decoder when the man field in mr register is set to 1, the manchester decoder is enabled. the decoder performs both preamble and start frame delimiter detection. one input line is dedicated to man- chester encoded input data. an optional preamble sequence can be defined, it s length is user-defined and totally indepen- dent of the emitter side. use rx_pl in man regi ster to configure the length of the preamble sequence. if the length is set to 0, no preamble is detected and the function is disabled. in addi- tion, the polarity of the input stream is programmable with rx_mpol field in man register. depending on the desired application the preamble pattern matching is to be defined via the rx_pp field in man. see figure 24-9 for available preamble patterns. unlike preamble, the start frame delimiter is shared between manchester encoder and decoder. so, if onebit field is set to 1, only a zero encoded manchester can be detected as a valid start frame delimiter. if onebit is set to 0, only a sync pattern is detected as a valid start frame delimiter. decoder operates by detecting transition on incoming stream. if rxd is sampled dur- ing one quarter of a bit time at zero, a start bit is detected. see figure 24-14 . the sample pulse rejection mechanism applies. sampling clock (x16) rxd start detection sampling baud rate clock rxd start rejection sampling 12345678 12345670 1234 12345678 9 10111213141516 d0 sampling d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit stop bit example: 8-bit, parity enabled baud rate clock start detection 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples
399 32054f?avr32?09/09 at32ap7002 figure 24-14. asynchronous star t bit detection the receiver is activated and starts preamble and frame delimiter detection, sampling the data at one quarter and then three quarters. if a valid preamble pattern or start frame delimiter is detected, the receiver continues decoding with the same synchronization. if the stream does not match a valid pattern or a valid start frame delimiter, the receiver re-synchronizes on the next valid edge.the minimum time threshold to estimate the bit value is three quarters of a bit time. if a valid preamble (if used) followed with a valid start frame delimiter is detected, the incoming stream is decoded into nrz data and passed to usart for processing. figure 24-15 illustrates manchester pattern mismatch. when incoming data stream is passed to the usart, the receiver is also able to detect manchester code vi olation. a code violation is a lack of transition in the middle of a bit cell. in this case, mane flag in csr register is raised. it is cleared by writing the control register (cr) with the rststa bit at 1. see figure 24-16 for an example of man- chester error detection during data phase. figure 24-15. preamble pattern mismatch figure 24-16. manchester error flag when the start frame delimiter is a sync pattern (onebit field at 0), both command and data delimiter are supported. if a valid sync is detec ted, the received character is written as rxchr manchester encoded data txd 1234 sampling clock (16 x) start detection manchester encoded data txd sfd data preamble length is set to 8 preamble mismatch invalid pattern preamble mismatch manchester coding error manchester encoded data txd sfd preamble length is set to 4 elementary character bit time manchester coding error detected sampling points preamble subpacket and start frame delimiter were successfully decoded entering usart character area
400 32054f?avr32?09/09 at32ap7002 field in the rhr register and the rxsynh is updated. rxchr is set to 1 when the received character is a command, and it is set to 0 if the received character is a data. this mechanism alleviates and simplifies the direct memory access as the character contains its own sync field in the same register. as the decoder is setup to be used in unipolar mode, the first bit of the frame has to be a zero-to- one transition. 24.7.3.6 radio interface: manchester encoded usart application this section describes low data rate rf transm ission systems and their integration with a man- chester encoded usart. these systems are based on transmitter and receiver ics that support ask and fsk modulation schemes. the goal is to perform full duplex radio transmissi on of characters using two different frequency carriers. see the configuration in figure 24-17 . figure 24-17. manchester encoded characters rf transmission the usart module is configured as a manchester encoder/decoder. looking at the down- stream communication channel, manchester encoded characters are serially sent to the rf emitter. this may also include a user defined preamble and a start frame delimiter. mostly, pre- amble is used in the rf receiver to distinguish between a valid data from a transmitter and signals due to noise. the manchester stream is then modulated. see figure 24-18 for an exam- ple of ask modulation scheme. when a logic one is sent to the ask modulator, the power amplifier, referred to as pa, is enabled and transmits an rf signal at downstream frequency. when a logic zero is transmitted, the rf signal is turned off. if the fsk modulator is activated, two different frequencies are used to transmit dat a. when a logic 1 is sent, the modulator out- puts an rf signal at frequency f0 and switches to f1 if the data sent is a 0. see figure 24-19 . from the receiver side, another carrier frequency is used. the rf receiver performs a bit check operation examining demodulated data stream. if a valid pattern is detected, the receiver switches to receiving mode. the demodulated stream is sent to the manchester decoder. because of bit checking inside rf ic, the data transferred to the microcontroller is reduced by a lna vco rf filter demod control bi-dir line pa rf filter mod vco control manchester decoder manchester encoder usart receiver usart emitter ask/fsk upstream receiver ask/fsk downstream transmitter upstream emitter downstream receiver serial configuration interface fup frequency carrier fdown frequency carrier
401 32054f?avr32?09/09 at32ap7002 user-defined number of bits. the manchester preamble length is to be defined in accordance with the rf ic configuration. figure 24-18. ask modulator output figure 24-19. fsk modulator output 24.7.3.7 synchronous receiver in synchronous mode (sync = 1), the receiver samples the rxd signal on each rising edge of the baud rate clock. if a lo w level is detected, it is considered as a start. all data bits, the parity bit and the stop bits are sampled and the receiver waits for the next start bit. synchronous mode operations provide a high speed transfer capability. configuration fields and bits are the same as in asynchronous mode. figure 24-20 illustrates a character rec eption in synchronous mode. figure 24-20. synchronous mode character reception manchester encoded data default polarity unipolar output txd ask modulator output uptstream frequency f0 nrz stream 10 0 1 manchester encoded data default polarity unipolar output txd fsk modulator output uptstream frequencies [f0, f0+offset] nrz stream 10 0 1 d0 d1 d2 d3 d4 d5 d6 d7 rxd start sampling parity bit stop bit example: 8-bit, parity enabled 1 stop baud rate clock
402 32054f?avr32?09/09 at32ap7002 24.7.3.8 receiver operations when a character reception is completed, it is transferred to the receive holding register (rhr) and the rxrdy bit in the st atus register (csr) rises. if a character is completed while the rxrdy is set, the ovre (overrun error) bit is set. the last character is transferred into rhr and overwrites the previous one. the ovre bit is cleared by writing the control register (cr) with the rststa (reset status) bit at 1. figure 24-21. receiver status d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write us_cr rxrdy ovre d0 d1 d2 d3 d4 d5 d6 d7 start bit parity bit stop bit rststa = 1 read us_rhr
403 32054f?avr32?09/09 at32ap7002 24.7.3.9 parity the usart supports five parity modes selected by programming the par field in the mode register (mr). the par field also enables the multidrop mode, see ?multidrop mode? on page 404 . even and odd parity bit generation and error detection are supported. if even parity is selected, the parity generator of the transmitter drives the parity bit at 0 if a num- ber of 1s in the character data bit is even, and at 1 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sam- pled parity bit does not correspond. if odd parity is selected, the parity generator of the transmitter drives the parity bit at 1 if a number of 1s in the character data bit is even, and at 0 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sampled parity bit does not correspond. if the mark parity is used, the parity generator of the transmitter drives the parity bit at 1 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 0. if the space parity is used, the parity generator of the transmitter drives the parity bit at 0 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 1. if parity is disabled, the transmitter does not generate any parity bit and the receiver does not report any parity error. table 24-6 shows an example of the parity bit for the character 0x41 (character ascii ?a?) depending on the configuration of the usart. because there are two bits at 1, 1 bit is added when a parity is odd, or 0 is added when a parity is even. when the receiver detects a parity error, it sets the pare (parity error) bit in the channel status register (csr). the pare bit can be cleared by writing the control register (cr) with the rst- sta bit at 1. figure 24-22 illustrates the parity bit status setting and clearing. table 24-6. parity bit examples character hexa binary parity bit parity mode a 0x41 0100 0001 1 odd a 0x41 0100 0001 0 even a 0x41 0100 0001 1 mark a 0x41 0100 0001 0 space a 0x41 0100 0001 none none
404 32054f?avr32?09/09 at32ap7002 figure 24-22. parity error 24.7.3.10 multidrop mode if the par field in the mode register (mr) is programmed to the value 0x6 or 0x07, the usart runs in multidrop mode. this mode differentia tes the data characters and the address charac- ters. data is transmitted with the parity bit at 0 and addresses are transmitted with the parity bit at 1. if the usart is configured in multidrop mode, the receiver sets the pare parity error bit when the parity bit is high and the transmitter is able to send a character with the parity bit high when the control register is written with the senda bit at 1. to handle parity error, the pare bit is cleared when the control register is written with the bit rststa at 1. the transmitter sends an address byte (parity bit set) when senda is written to cr. in this case, the next byte written to thr is transmitted as an address. any character written in thr without having written the command senda is transmitted normally with the parity at 0. 24.7.3.11 transmitter timeguard the timeguard feature enables the usar t interface with slow remote devices. the timeguard function enables the transmitter to insert an idle state on the txd line between two characters. this idle state actually acts as a long stop bit. the duration of the idle state is programmed in the tg field of the transmitter timeguard regis- ter (ttgr). when this field is programmed at zero no timeguard is generated. otherwise, the transmitter holds a high level on txd after each transmitted byte during the number of bit peri- ods programmed in tg in addition to the number of stop bits. as illustrated in figure 24-23 , the behavior of txrdy and txempty status bits is modified by the programming of a timeguard. txrdy rises only when the start bit of the next character is sent, and thus remains at 0 during the timeguard transmission if a character has been written in thr. txempty remains low until the timeguard transmission is completed as the timeguard is part of the current character being transmitted. d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit bad parity bit stop bit baud rate clock write us_cr pare rxrdy rststa = 1
405 32054f?avr32?09/09 at32ap7002 figure 24-23. timeguard operations table 24-7 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the function of the baud rate. 24.7.3.12 receiver time-out the receiver time-out provides support in handling variable-length frames. this feature detects an idle condition on the rxd line. when a time-out is detected, the bit timeout in the channel status register (csr) rises and can generate an interrupt, thus indicating to the driver an end of frame. the time-out delay period (during which the receiver waits for a new character) is programmed in the to field of the receiver time-out register (rtor). if the to field is programmed at 0, the receiver time-out is disabled and no time-out is detected. the timeou t bit in csr remains at 0. otherwise, the receiver loads a 16-bit counter with the value programmed in to. this counter is decremented at each bit period and reloaded ea ch time a new character is received. if the counter reaches 0, the timeout bit in the status register rises. the user can either: d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit tg = 4 write us_thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty tg = 4 table 24-7. maximum timeguard length depending on baud rate baud rate bit time timeguard bit/sec s ms 1 200 833 212.50 9 600 104 26.56 14400 69.4 17.71 19200 52.1 13.28 28800 34.7 8.85 33400 29.9 7.63 56000 17.9 4.55 57600 17.4 4.43 115200 8.7 2.21
406 32054f?avr32?09/09 at32ap7002 ?obtain an interrupt when a time-out is detected after having received at least one character. this is performed by writing the control regist er (cr) with the sttto (start time-out) bit at 1. ?obtain a periodic interrupt while no character is received. this is performed by writing cr with the retto (reload and start time-out) bit at 1. if sttto is performed, the counter clock is stopped until a first character is received. the idle state on rxd before the start of the frame does not provide a time-out. this prevents having to obtain a periodic interrupt and enables a wait of the end of frame when the idle state on rxd is detected. if retto is performed, the counter starts counting down immediately from the value to. this enables generation of a periodic interrupt so t hat a user time-out can be handled, for example when no key is pressed on a keyboard. figure 24-24 shows the block diagram of the receiver time-out feature. figure 24-24. receiver time-out block diagram table 24-8 gives the maximum time-out period for some standard baud rates. 16-bit time-out counter 0 to timeout baud rate clock = character received retto load clock 16-bit value sttto dq 1 clear table 24-8. maximum time-out period baud rate bit time time-out bit/sec s ms 600 1 667 109 225 1 200 833 54 613 2 400 417 27 306 4 800 208 13 653 9 600 104 6 827 14400 69 4 551 19200 52 3 413 28800 35 2 276 33400 30 1 962 56000 18 1 170 57600 17 1 138 200000 5 328
407 32054f?avr32?09/09 at32ap7002 24.7.3.13 framing error the receiver is capable of detecting framing errors. a framing error happens when the stop bit of a received character is detected at level 0. this can occur if the receiver and the transmitter are fully desynchronized. a framing error is reported on the frame bit of the channel status register (csr). the frame bit is asserted in the middle of the stop bit as soon as the framing error is detected. it is cleared by writing the control register (cr) with the rststa bit at 1. figure 24-25. framing error status 24.7.3.14 transmit break the user can request the transmitter to generate a break condition on the txd line. a break con- dition drives the txd line low during at least one complete character. it appears the same as a 0x00 character sent with the parity and the stop bits at 0. however, the transmitter holds the txd line at least during one character until the user requests the break condition to be removed. a break is transmitted by writing the control register (cr) with the sttbrk bit at 1. this can be performed at any time, either while the transmitter is empty (no character in either the shift reg- ister or in thr) or when a character is being transmitted. if a break is requested while a character is being shifted out, t he character is first completed be fore the txd line is held low. once sttbrk command is requested further sttbrk commands are ignored until the end of the break is completed. the break condition is removed by writing cr with the stpbrk bit at 1. if the stpbrk is requested before the end of the minimum break duration (one character, including start, data, parity and stop bits), the transmitter ensures that the break condition completes. the transmitter considers the break as though it is a character, i.e. the sttbrk and stpbrk commands are taken into account only if the txrdy bit in csr is at 1 and the start of the break condition clears the txrdy and txempty bits as if a character is processed. writing cr with the both sttbrk and stpbrk bits at 1 can lead to an unpredictable result. all stpbrk commands requested without a previous sttbrk command are ignored. a byte writ- ten into the transmit holding re gister while a break is pending, but not started, is ignored. d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write us_cr frame rxrdy rststa = 1
408 32054f?avr32?09/09 at32ap7002 after the break condition, the transmitter returns the txd line to 1 for a minimum of 12 bit times. thus, the transmitter ensures that the remote receiver detects correctly the end of break and the start of the next character. if the timeguard is programmed with a value higher than 12, the txd line is held high for the timeguard period. after holding the txd line for this period, the transmitter resumes normal operations. figure 24-26 illustrates the effect of both the start break (sttbrk ) and stop break (stpbrk) commands on the txd line. figure 24-26. break transmission 24.7.3.15 receive break the receiver detects a break condition when all data, parity and stop bits are low. this corre- sponds to detecting a framing error with data at 0x00, but frame remains low. when the low stop bit is detected, the receiver asserts the rxbrk bit in csr. this bit may be cleared by writing the control register (cr) with the bit rststa at 1. an end of receive break is detected by a high leve l for at least 2/16 of a bit period in asynchro- nous operating mode or one sample at high level in synchronous operating mode. the end of break detection also asserts the rxbrk bit. 24.7.3.16 hardware handshaking the usart features a hardware handshaking out-of-band flow control. the rts and cts pins are used to connect with the remote device, as shown in figure 24-27 . figure 24-27. connection with a remote device for hardware handshaking d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock write us_cr txrdy txempty stpbrk = 1 sttbrk = 1 break transmission end of break usart txd cts remote device rxd txd rxd rts rts cts
409 32054f?avr32?09/09 at32ap7002 setting the usart to operate with hardware handshaking is performed by writing the mode field in the mode register (mr) to the value 0x2. the usart behavior when hardware handshaking is enabled is the same as the behavior in standard synchronous or asynchronous mode, except that the receiver drives the rts pin as described below and the level on the cts pin modifies the behavior of the transmitter as described below. using this mode requires usin g the pdc channel for reception. the transmitter can handle hardware handshaking in any case. figure 24-28 shows how the receiver operates if hardware handshaking is enabled. the rts pin is driven high if the receiver is disabled and if the status rxbuff (receive buffer full) com- ing from the pdc channel is high. normally, the remote device does not start transmitting while its cts pin (driven by rts) is high. as soon as the receiver is enabled , the rts falls, indicating to the remote device that it can start transmitt ing. defining a new buffer to the pdc clears the status bit rxbuff and, as a result, asserts the pin rts low. figure 24-28. receiver behavior when operating with hardware handshaking figure 24-29 shows how the transmitter operates if hardware handshaking is enabled. the cts pin disables the transmitt er. if a character is being processi ng, the transmitter is disabled only after the completion of the current character and transmission of the next character happens as soon as the pin cts falls. figure 24-29. transmitter behavior when operating with hardware handshaking 24.7.4 iso7816 mode the usart features an iso7816-compatible operating mode. this mode permits interfacing with smart cards and security access modules (sam) communicating through an iso7816 link. both t = 0 and t = 1 protocols defined by the iso7816 specification are supported. setting the usart in iso7816 mode is performed by writing the mode field in the mode regis- ter (mr) to the value 0x4 for protocol t = 0 and to the value 0x5 for protocol t = 1. 24.7.4.1 iso7816 mode overview the iso7816 is a half duplex communication on only one bidirectional line. the baud rate is determined by a division of the clo ck provided to the remote device (see ?baud rate generator? on page 388 ). rts rxbuff write us_cr rxen = 1 rxd rxdis = 1 cts txd
410 32054f?avr32?09/09 at32ap7002 the usart connects to a smart card as shown in figure 24-30 . the txd line becomes bidirec- tional and the baud rate generator feeds the iso7816 clock on the clk pin. as the txd pin becomes bidirectional, its output remains driven by the output of the transmitter but only when the transmitter is active while its input is direct ed to the input of the receiver. the usart is con- sidered as the master of the communication as it generates the clock. figure 24-30. connection of a smart card to the usart when operating in iso7816, either in t = 0 or t = 1 modes, the character format is fixed. the configuration is 8 data bits, ev en parity and 1 or 2 stop bits, regardless of the values pro- grammed in the chrl, mode9, par and chmode fields. msbf can be used to transmit lsb or msb first. parity bit (par) can be used to transmit in normal or inverse mode. refer to ?usart mode register? on page 421 and ?par: parity type? on page 422 . the usart cannot operate concurrently in both receiver and transmitter modes as the commu- nication is unidirectional at a time. it has to be configured according to the required mode by enabling or disabling either the receiver or the transmitter as desired. enabling both the receiver and the transmitter at the same time in iso7816 mode may lead to unpredictable results. the iso7816 specification defines an inverse transmission format. data bits of the character must be transmitted on the i/o line at their negative value. the usart does not support this for- mat and the user has to perform an exclusive or on the data before writing it in the transmit holding register (thr) or after reading it in the receive holding register (rhr). 24.7.4.2 protocol t = 0 in t = 0 protocol, a character is made up of one start bit, eight data bits, one parity bit and one guard time, which lasts two bit times. the transmitter shifts out the bits and does not drive the i/o line during the guard time. if no parity error is detected, the i/o line remains at 1 during the guard time and the transmitter can continue with the transmission of the next character, as shown in figure 24-31 . if a parity error is detected by the receiver, it drives the i/o line at 0 during the guard time, as shown in figure 24-32 . this error bit is also named nack, for non acknowledge. in this case, the character lasts 1 bit time more, as the guard time length is the same and is added to the error bit time which lasts 1 bit time. when the usart is the receiver and it detects an error, it does not load the erroneous character in the receive holding register (rhr). it appropriately sets the pare bit in the status register (sr) so that the software can handle the error. clk txd usart clk i/o smart card
411 32054f?avr32?09/09 at32ap7002 figure 24-31. t = 0 protocol without parity error figure 24-32. t = 0 protocol with parity error 24.7.4.3 receive error counter the usart receiver also records the total number of errors. this can be read in the number of error (ner) register. the nb_errors field ca n record up to 255 errors. reading ner auto- matically clears the nb_errors field. 24.7.4.4 receive nack inhibit the usart can also be configured to inhibit an error. this can be achieved by setting the inack bit in the mode register (mr). if inack is at 1, no error signal is driven on the i/o line even if a parity bit is detected, but the inack bit is set in the status register (sr). the inack bit can be cleared by writing the control re gister (cr) with the rstnack bit at 1. moreover, if inack is set, the erroneous receiv ed character is stored in the receive holding register, as if no error occurred. however, the rxrdy bit does not raise. 24.7.4.5 transmit character repetition when the usart is transmitting a character and gets a nack, it can automatically repeat the character before moving on to the next one. repetition is enabled by writing the max_iteration field in the mode register (mr) at a value higher than 0. each character can be transmitted up to eight times; the firs t transmission plus seven repetitions. if max_iteration does not equal zero, the u sart repeats the character as many times as the value loaded in max_iteration. when the usart repetition number reaches max_iteration, the iteration bit is set in the channel status register (csr). if the repetition of the character is acknowledged by the receiver, the repetitions are stopped and the iteration counter is cleared. the iteration bit in csr can be cleared by writing the control register with the rsit bit at 1. 24.7.4.6 disable successive receive nack the receiver can limit the number of successive nacks sent back to the remote transmitter. this is programmed by setting the bit dsnack in the mode register (mr). the maximum num- ber of nack transmitted is programmed in the max_iteration field. as soon as d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit baud rate clock start bit guard time 1 next start bit guard time 2 d0 d1 d2 d3 d4 d5 d6 d7 i/o parity bit baud rate clock start bit guard time 1 start bit guard time 2 d0 d1 error repetition
412 32054f?avr32?09/09 at32ap7002 max_iteration is reached, the character is cons idered as correct, an acknowledge is sent on the line and the iteration bit in the channel status register is set. 24.7.4.7 protocol t = 1 when operating in iso7816 protocol t = 1, the transmission is similar to an asynchronous for- mat with only one stop bit. the parity is generated when transmitting and checked when receiving. parity error detection sets the par e bit in the channel status register (csr). 24.7.5 irda mode the usart features an irda mode supplying half-duplex point-to-point wireless communica- tion. it embeds the modulator and demodulator which allows a glueless connection to the infrared transceivers, as shown in figure 24-33 . the modulator and demodulator are compliant with the irda specification version 1.1 and support data transfer speeds ranging from 2.4 kb/s to 115.2 kb/s. the usart irda mode is enabled by setting the mo de field in the mode register (mr) to the value 0x8. the irda filter register (ifr) allo ws configuring the demodulator filter. the usart transmitter and receiver operate in a normal asynchronous mode and all parameters are acces- sible. note that the modulator and the demodulator are activated. figure 24-33. connection to irda transceivers the receiver and the transmitter must be enabled or disabled according to the direction of the transmission to be managed. 24.7.5.1 irda modulation for baud rates up to and including 115.2 kbits/sec, the rzi modulation scheme is used. ?0? is represented by a light pulse of 3/16th of a bit time. some examples of signal pulse duration are shown in table 24-9 . irda transceivers rxd rx txd tx usart demodulator modulator receiver transmitter table 24-9. irda pulse duration baud rate pulse duration (3/16) 2.4 kb/s 78.13 s 9.6 kb/s 19.53 s 19.2 kb/s 9.77 s
413 32054f?avr32?09/09 at32ap7002 figure 24-34 shows an example of character transmission. figure 24-34. irda modulation 24.7.5.2 irda baud rate table 24-10 gives some examples of cd values, baud rate error and pulse duration. note that the requirement on the maximum acceptable error of 1.87% must be met. 38.4 kb/s 4.88 s 57.6 kb/s 3.26 s 115.2 kb/s 1.63 s table 24-9. irda pulse duration baud rate pulse duration (3/16) bit period bit period 3 16 start bit data bits stop bit 0 0 0 0 0 1 1 1 1 1 transmitter output txd table 24-10. irda baud rate error peripheral clock baud rate cd baud rate error pulse time 3 686 400 115 200 2 0.00% 1.63 20 000 000 115 200 11 1.38% 1.63 32 768 000 115 200 18 1.25% 1.63 40 000 000 115 200 22 1.38% 1.63 3 686 400 57 600 4 0.00% 3.26 20 000 000 57 600 22 1.38% 3.26 32 768 000 57 600 36 1.25% 3.26 40 000 000 57 600 43 0.93% 3.26 3 686 400 38 400 6 0.00% 4.88 20 000 000 38 400 33 1.38% 4.88 32 768 000 38 400 53 0.63% 4.88 40 000 000 38 400 65 0.16% 4.88 3 686 400 19 200 12 0.00% 9.77 20 000 000 19 200 65 0.16% 9.77 32 768 000 19 200 107 0.31% 9.77 40 000 000 19 200 130 0.16% 9.77
414 32054f?avr32?09/09 at32ap7002 24.7.5.3 irda demodulator the demodulator is based on the irda receive filter co mprised of an 8-bit down counter which is loaded with the value programmed in ifr. when a falling edge is detected on the rxd pin, the filter counter starts counting down at the clk_usart speed. if a rising edge is detected on the rxd pin, the counter stops and is reloaded with ifr. if no rising edge is detected when the counter reaches 0, the input of the receiver is driven low during one bit time. figure 24-35 illustrates the operations of the irda demodulator. figure 24-35. irda demodulator operations as the irda mode uses the same logic as the iso7816, note that the fi_di_ratio field in fidi must be set to a value higher than 0 in order to assure irda communications operate correctly. 3 686 400 9 600 24 0.00% 19.53 20 000 000 9 600 130 0.16% 19.53 32 768 000 9 600 213 0.16% 19.53 40 000 000 9 600 260 0.16% 19.53 3 686 400 2 400 96 0.00% 78.13 20 000 000 2 400 521 0.03% 78.13 32 768 000 2 400 853 0.04% 78.13 table 24-10. irda baud rate error (continued) peripheral clock baud rate cd baud rate error pulse time clk_usart rxd counter value receiver input 654 6 3 pulse rejected 264 53210 pulse accepted driven low during 16 baud rate clock cycles
415 32054f?avr32?09/09 at32ap7002 24.7.6 rs485 mode the usart features the rs485 mode to enable li ne driver control. while operating in rs485 mode, the usart behaves as though in asynch ronous or synchronous mode and configuration of all the parameters is possible. the differenc e is that the rts pin is driven high when the transmitter is operating. the behavior of the rts pin is controlled by the txempty bit. a typical connection of the usart to a rs485 bus is shown in figure 24-36 . figure 24-36. typical connection to a rs485 bus the usart is set in rs485 mode by programming the mode field in the mode register (mr) to the value 0x1. the rts pin is at a level inverse to the txempt y bit. significantly, the rts pin remains high when a timeguard is programmed so that the line can remain driven after the last character com- pletion. figure 24-37 gives an example of the rts waveform during a character transmission when the timeguard is enabled. figure 24-37. example of rts drive with timeguard usart rts txd rxd differential bus d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock tg = 4 write us_thr txrdy txempty rts
416 32054f?avr32?09/09 at32ap7002 24.7.7 test modes the usart can be programmed to operate in three different test modes. the internal loopback capability allows on-boar d diagnostics. in the loopback mode the usart interface pins are dis- connected or not and reconfigured for loopback internally or externally. 24.7.7.1 normal mode normal mode connects the rxd pin on the receiver input and the transmitter output on the txd pin. figure 24-38. normal mode configuration 24.7.7.2 automatic echo mode automatic echo mode allows bit-by-bit retransmission. when a bit is received on the rxd pin, it is sent to the txd pin, as shown in figure 24-39 . programming the transmitter has no effect on the txd pin. the rxd pin is still connected to the receiver input, thus the receiver remains active. figure 24-39. automatic echo mode configuration 24.7.7.3 local loopback mode local loopback mode c onnects the output of the transmitter directly to the input of the receiver, as shown in figure 24-40 . the txd and rxd pins are not used. the rxd pin has no effect on the receiver and the txd pin is continuously driven high, as in idle state. figure 24-40. local loopback mode configuration receiver transmitter rxd txd receiver transmitter rxd txd receiver transmitter rxd txd 1
417 32054f?avr32?09/09 at32ap7002 24.7.7.4 remote loopback mode remote loopback mode directly connects the rxd pin to the txd pin, as shown in figure 24-41 . the transmitter and the receiver are disabled an d have no effect. this mode allows bit-by-bit retransmission. figure 24-41. remote loopback mode configuration receiver transmitter rxd txd 1
418 32054f?avr32?09/09 at32ap7002 24.8 usart user interface note: 1. values in the version register vary wit h the version of the ip block implementation. table 24-11. usart memory map offset register name access reset state 0x0000 control register cr write-only ? 0x0004 mode register mr read/write ? 0x0008 interrupt enable register ier write-only ? 0x000c interrupt disable register idr write-only ? 0x0010 interrupt mask register imr read-only 0x0 0x0014 channel status register csr read-only ? 0x0018 receiver holding register rhr read-only 0x0 0x001c transmitter holding register thr write-only ? 0x0020 baud rate generator register brgr read/write 0x0 0x0024 receiver time-out register rtor read/write 0x0 0x0028 transmitter timeguard register ttgr read/write 0x0 0x2c - 0x3c reserved ? ? ? 0x0040 fi di ratio register fidi read/write 0x174 0x0044 number of errors register ner read-only ? 0x0048 reserved - ? ? 0x004c irda filter register ifr read/write 0x0 0x0050 manchester encoder decoder register man read/write 0x30011004 0x5c - 0xf8 reserved ? ? ? 0xfc version register us_version read-only 0x? (1) 0x100 - 0x128 reserved for pdc registers ? ? ?
419 32054f?avr32?09/09 at32ap7002 24.8.1 usart control register name: cr access type: write-only offset: 0x00 reset value: - ? rstrx: reset receiver 0: no effect. 1: resets the receiver. ? rsttx: reset transmitter 0: no effect. 1: resets the transmitter. ? rxen: receiver enable 0: no effect. 1: enables the receiver, if rxdis is 0. ? rxdis: receiver disable 0: no effect. 1: disables the receiver. ? txen: transmitter enable 0: no effect. 1: enables the transmitter if txdis is 0. ? txdis: transmitter disable 0: no effect. 1: disables the transmitter. ? rststa: reset status bits 0: no effect. 1: resets the status bits pare, frame, ovre, manerr and rxbrk in csr. ? sttbrk: start break 0: no effect. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rtsdisrtsen?? 15 14 13 12 11 10 9 8 retto rstnack rstit senda sttto stpbrk sttbrk rststa 76543210 txdis txen rxdis rxen rsttx rstrx ? ?
420 32054f?avr32?09/09 at32ap7002 1: starts transmission of a break after t he characters present in thr and the transmit shift register have been transmit- ted. no effect if a break is already being transmitted. ? stpbrk: stop break 0: no effect. 1: stops transmission of the break after a minimum of one char acter length and transmits a high level during 12-bit periods. no effect if no break is being transmitted. ? sttto: start time-out 0: no effect 1: starts waiting for a character before clocking the time-out counter. ? senda: send address 0: no effect. 1: in multidrop mode only, the next character written to the thr is sent with the address bit set. ? rstit: reset iterations 0: no effect. 1: resets iteration in csr. no e ffect if the iso7816 is not enabled. ? rstnack: reset non acknowledge 0: no effect 1: resets nack in csr. ? retto: rearm time-out 0: no effect 1: restart time-out ? rtsen: request to send enable 0: no effect. 1: drives the pin rts to 0. ? rtsdis: request to send disable 0: no effect. 1: drives the pin rts to 1.
421 32054f?avr32?09/09 at32ap7002 24.8.2 usart mode register name: mr access type: read/write ?mode ? usclks: clock selection ? chrl: character length. 31 30 29 28 27 26 25 24 onebit modsync man filter ? max_iteration 23 22 21 20 19 18 17 16 ? var_sync dsnack inack over clko mode9 msbf 15 14 13 12 11 10 9 8 chmode nbstop par sync 76543210 chrl usclks mode mode mode of the usart 0000normal 0001rs485 0 0 1 0 hardware handshaking 0011reserved 0 1 0 0 is07816 protocol: t = 0 0101reserved 0 1 1 0 is07816 protocol: t = 1 0111reserved 1000irda 11xxreserved usclks selected clock 00 clk_usart 01 clk_usart / div 10reserved 11clk chrl character length 0 0 5 bits
422 32054f?avr32?09/09 at32ap7002 ? sync: synchronous mode select 0: usart operates in asynchronous mode. 1: usart operates in synchronous mode. ? par: parity type ? nbstop: number of stop bits ? chmode: channel mode ? msbf: bit order 0: least significant bit is sent/received first. 1: most significant bit is sent/received first. ? mode9: 9-bit character length 0: chrl defines character length. 1: 9-bit character length. ? clko: clock output select 0: the usart does not drive the clk pin. 0 1 6 bits 1 0 7 bits 1 1 8 bits par parity type 0 0 0 even parity 001odd parity 0 1 0 parity forced to 0 (space) 0 1 1 parity forced to 1 (mark) 1 0 x no parity 1 1 x multidrop mode nbstop asynchronous (sync = 0) synchronous (sync = 1) 0 0 1 stop bit 1 stop bit 0 1 1.5 stop bits reserved 1 0 2 stop bits 2 stop bits 1 1 reserved reserved chmode mode description 0 0 normal mode 0 1 automatic echo. receiver input is connected to the txd pin. 1 0 local loopback. transmitter output is connected to the receiver input.. 1 1 remote loopback. rxd pin is internally connected to the txd pin.
423 32054f?avr32?09/09 at32ap7002 1: the usart drives the clk pin if usclks does not select the external clock clk. ? over: oversampling mode 0: 16x oversampling. 1: 8x oversampling. ? inack: inhibit non acknowledge 0: the nack is generated. 1: the nack is not generated. ? dsnack: disable successive nack 0: nack is sent on the iso line as soon as a parity erro r occurs in the received character (unless inack is set). 1: successive parity errors are counted up to the value spec ified in the max_iteration field. these parity errors gener- ate a nack on the iso line. as soon as this value is r eached, no additional nack is sent on the iso line. the flag iteration is asserted. ? var_sync: variable synchronization of command/data sync start frame delimiter 0: user defined configuration of command or data sync field depending on sync value. 1: the sync field is updated when a ch aracter is written into thr register. ? max_iteration defines the maximum number of iterations in mode iso7816, protocol t= 0. ? filter: infrared receive line filter 0: the usart does not filter the receive line. 1: the usart filters the receive line using a three-sample filter (1/16-bit clock) (2 over 3 majority). ? man: manchester encoder/decoder enable 0: manchester encoder/decoder are disabled. 1: manchester encoder/decoder are enabled. ? modsync : manchester synchronization mode 0:the manchester start bit is a 0 to 1 transition 1: the manchester start bit is a 1 to 0 transition. ? onebit: start frame delimiter selector 0: start frame delimiter is command or data sync. 1: start frame delimiter is one bit.
424 32054f?avr32?09/09 at32ap7002 24.8.3 usart interrupt enable register name: ier access type: write-only ? rxrdy: rxrdy interrupt enable ? txrdy: txrdy interrupt enable ? rxbrk: receiver break interrupt enable ? endrx: end of receive transfer interrupt enable ? endtx: end of transmit interrupt enable ? ovre: overrun error interrupt enable ? frame: framing error interrupt enable ? pare: parity error interrupt enable ? timeout: time-out interrupt enable ? txempty: txempty interrupt enable ? iteration: iteration interrupt enable ? txbufe: buffer empty interrupt enable ? rxbuff: buffer full interrupt enable ? nack: non acknowledge interrupt enable ? ctsic: clear to send input change interrupt enable ? mane: manchester error interrupt enable 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? mane ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
425 32054f?avr32?09/09 at32ap7002 24.8.4 usart interrupt disable register name: idr access type: write-only ? rxrdy: rxrdy interrupt disable ? txrdy: txrdy interrupt disable ? rxbrk: receiver bre ak interrupt disable ? endrx: end of receive transfer interrupt disable ? endtx: end of transmit interrupt disable ? ovre: overrun error interrupt disable ? frame: framing error interrupt disable ? pare: parity error interrupt disable ? timeout: time-out interrupt disable ? txempty: txempty interrupt disable ? iteration: iteration interrupt disable ? txbufe: buffer empty interrupt disable ? rxbuff: buffer full interrupt disable ? nack: non acknowledge interrupt disable ? ctsic: clear to send input change interrupt disable ? mane: manchester error interrupt disable 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? mane ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
426 32054f?avr32?09/09 at32ap7002 24.8.5 usart interrupt mask register name: imr access type: read-only ? rxrdy: rxrdy interrupt mask ? txrdy: txrdy interrupt mask ? rxbrk: receiver break interrupt mask ? endrx: end of receive transfer interrupt mask ? endtx: end of transmit interrupt mask ? ovre: overrun error interrupt mask ? frame: framing error interrupt mask ? pare: parity error interrupt mask ? timeout: time-out interrupt mask ? txempty: txempty interrupt mask ? iteration: iteration interrupt mask ? txbufe: buffer empty interrupt mask ? rxbuff: buffer full interrupt mask ? nack: non acknowledge interrupt mask ? ctsic: clear to send input change interrupt mask ? mane: manchester error interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? mane ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
427 32054f?avr32?09/09 at32ap7002 24.8.6 usart channel status register name: csr access type: read-only ? rxrdy: receiver ready 0: no complete character has been received since the last read of rhr or the receiver is disabled. if characters were being received when the receiver was disabled, rxrdy changes to 1 when the receiver is enabled. 1: at least one complete ch aracter has been re ceived and rhr has not yet been read. ? txrdy: transmitter ready 0: a character is in the thr waiting to be transferred to the transmit shift register, or an sttbrk command has been requested, or the transmitter is disabled. as soon as the transmitter is enabled, txrdy becomes 1. 1: there is no character in the thr. ? rxbrk: break received/end of break 0: no break received or end of break detected since the last rststa. 1: break received or end of break detected since the last rststa. ? endrx: end of receiver transfer 0: the end of transfer signal from the receive pdc channel is inactive. 1: the end of transfer signal from the receive pdc channel is active. ? endtx: end of transmitter transfer 0: the end of transfer signal from the transmit pdc channel is inactive. 1: the end of transfer signal from the transmit pdc channel is active. ? ovre: overrun error 0: no overrun error has occurred since the last rststa. 1: at least one overrun error has occurred since the last rststa. ? frame: framing error 0: no stop bit has been detected low since the last rststa. 1: at least one stop bit has been detected low since the last rststa. ? pare: parity error 0: no parity error has been detected since the last rststa. 31 30 29 28 27 26 25 24 ???????manerr 23 22 21 20 19 18 17 16 cts ? ? ? ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
428 32054f?avr32?09/09 at32ap7002 1: at least one parity error has been detected since the last rststa. ? timeout: receiver time-out 0: there has not been a time-out since the last start time-out command or the time-out register is 0. 1: there has been a time-out since the last start time-out command. ? txempty: transmitter empty 0: there are characters in either thr or the trans mit shift register, or the transmitter is disabled. txempty == 1 means that the transmit shift register is empty and that there is no data in thr. ? iteration: max number of repetitions reached 0: maximum number of repetitions has not been reached since the last rsit. 1: maximum number of repetitions has been reached since the last rsit. ? txbufe: transmission buffer empty 0: the signal buffer empty from the transmit pdc channel is inactive. 1: the signal buffer empty from the transmit pdc channel is active. ? rxbuff: reception buffer full 0: the signal buffer full from the receive pdc channel is inactive. 1: the signal buffer full from th e receive pdc channel is active. ? nack: non acknowledge 0: no non acknowledge has not been detected since the last rstnack. 1: at least one non acknowledge has been detected since the last rstnack. ? ctsic: clear to send input change flag 0: no input change has been detected on the cts pin since the last read of csr. 1: at least one input change has been detected on the cts pin since the last read of csr. ? cts: image of cts input 0: cts is at 0. 1: cts is at 1. ? manerr: manchester error 0: no manchester error has been detected since the last rststa. 1: at least one manchester error has been detected since the last rststa.
429 32054f?avr32?09/09 at32ap7002 24.8.7 usart receive holding register name: rhr access type: read-only ? rxchr: received character last character received if rxrdy is set. ? rxsynh: received sync 0: last character received is a data. 1: last character received is a command. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rxsynh ??????rxchr 76543210 rxchr
430 32054f?avr32?09/09 at32ap7002 24.8.8 usart transmit holding register name: thr access type: write-only ? txchr: character to be transmitted next character to be transmitted after the current character if txrdy is not set. ? txsynh: sync field to be transmitted 0: the next character sent is encoded as a data. start frame delimiter is data sync. 1: the next character sent is encoded as a command. start frame delimiter is command sync. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 txsynh ??????txchr 76543210 txchr
431 32054f?avr32?09/09 at32ap7002 24.8.9 usart baud rate generator register name: brgr access type: read/write ? cd: clock divider ? fp: fractional part 0: fractional divider is disabled. 1 - 7: baudrate resolution, defined by fp x 1/8. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? fp 15 14 13 12 11 10 9 8 cd 76543210 cd cd mode iso7816 mode = iso7816 sync = 0 sync = 1 over = 0 over = 1 0 baud rate clock disabled 1 to 65535 baud rate = selected clock/16/cd baud rate = selected clock/8/cd baud rate = selected clock /cd baud rate = selected clock/cd/fi_di_ratio
432 32054f?avr32?09/09 at32ap7002 24.8.10 usart receiver time-out register name: rtor access type: read/write ? to: time-out value 0: the receiver time-out is disabled. 1 - 65535: the receiver time-out is enabled and the time-out delay is to x bit period. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 to 76543210 to
433 32054f?avr32?09/09 at32ap7002 24.8.11 usart transmitter timeguard register name: ttgr access type: read/write ? tg: timeguard value 0: the transmitter timeguard is disabled. 1 - 255: the transmitter timeguard is enabled and the timeguard delay is tg x bit period. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 tg
434 32054f?avr32?09/09 at32ap7002 24.8.12 usart fi di ratio register name: fidi access type: read/write reset value : 0x174 ? fi_di_ratio: fi over di ratio value 0: if iso7816 mode is selected, the baud rate generator generates no signal. 1 - 2047: if iso7816 mode is selected, the baud rate is the clock provided on clk divided by fi_di_ratio. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? fi_di_ratio 76543210 fi_di_ratio
435 32054f?avr32?09/09 at32ap7002 24.8.13 usart number of errors register name: ner access type: read-only ? nb_errors: number of errors total number of errors that occurred during an iso7816 transfer. this register automatically clears when read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 nb_errors
436 32054f?avr32?09/09 at32ap7002 24.8.14 usart manchester configuration register name: man access type: read/write ? tx_pl: transmitter preamble length 0: the transmitter preamble pattern generation is disabled 1 - 15: the preamble length is tx_pl x bit period ? tx_pp: transmitter preamble pattern ? tx_mpol: transmitter manchester polarity 0: logic zero is coded as a zero-to-one transition , logic one is coded as a one-to-zero transition. 1: logic zero is coded as a one-to-zero transition , logic one is coded as a zero-to-one transition. ? rx_pl: receiver preamble length 0: the receiver preamble pattern detection is disabled 1 - 15: the detected preamble length is rx_pl x bit period ? rx_pp: receiver preamble pattern detected ? rx_mpol: receiver manchester polarity 0: logic zero is coded as a zero-to-one transition , logic one is coded as a one-to-zero transition. 31 30 29 28 27 26 25 24 ? drift ? rx_mpol ? ? rx_pp 23 22 21 20 19 18 17 16 ???? rx_pl 15 14 13 12 11 10 9 8 ? ? ? tx_mpol ? ? tx_pp 76543210 ???? tx_pl tx_pp preamble pattern default polari ty assumed (tx_mpol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero rx_pp preamble pattern de fault polarity assumed (rx_mpol fi eld not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
437 32054f?avr32?09/09 at32ap7002 1: logic zero is coded as a one-to-zero transition , logic one is coded as a zero-to-one transition. ? drift: drift compensation 0: the usart can not recover from an important clock drift 1: the usart can recover from clock drift. the 16x clock mode must be enabled.
438 32054f?avr32?09/09 at32ap7002 24.8.15 usart irda filter register name: ifr access type: read/write ? irda_filter: irda filter sets the filter of the irda demodulator. 24.9 usart version register name: us_version access type: read-only ? version reserved. value subject to change. no functionality associat ed. this is the atmel internal version of the macrocell. ?mfn reserved. value subject to change. no functionality associated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 irda_filter 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? mfn 15 14 13 12 11 10 9 8 ???? version 76543210 version
439 32054f?avr32?09/09 at32ap7002 25. ac97 controller (ac97c) rev: 2.1.0.0 25.1 features ? compliant with ac97 2.2 component specification ? 2 independent comm unication channels ? codec channel, dedicated to the ac97 analog front end control and status monitoring ? 2 channels associated with dma controller interface for isochronous audio streaming transfer ? variable sampling rate ac 97 codec interface support ? one primary codec support ? independent input and output slot to channel assignment, several slots can be assigned to the same channel. ? channels support mono/stereo/multichann el samples of 10, 16, 18 and 20 bits. 25.2 description the ac97 controller is the hardware implementation of the ac97 digital controller (dc?97) com- pliant with ac97 component specification 2.2. the ac97 controller communicates with an audio codec (ac97) or a modem codec (mc?97) via the ac-link digital serial interface. all digital audio, modem and handset data streams, as well as control (command/status) informations are transferred in accordance to the ac-link protocol. the ac97 controller features a dma controller interface for audio streaming transfers. it also supports variable sampling rate and four puls e code modulation (pcm) sample resolutions of 10, 16, 18 and 20 bits.
440 32054f?avr32?09/09 at32ap7002 25.3 block diagram figure 25-1. functional block diagram ac97 channel a ac97c_cathr ac97c_carhr slot #3...12 ac97 codec channel ac97c_cothr ac97c_corhr slot #2 slot #1,2 ac97 channel b ac97c_cbthr ac97c_cbrhr slot #3...12 ac97 tag controller transmit shift register receive shift register receive shift register receive shift register receive shift register transmit shift register transmit shift register transmit shift register slot #0 slot #0,1 ac97 slot controller slot number 16/20 bits slot number sdi sclk sdo sync user interface mck clock domain bit clock domain ac97c interrupt mck peripheral bus m u x d e m u x
441 32054f?avr32?09/09 at32ap7002 25.4 pin name list the ac97 reset signal provided to the primary codec can be generated by a pio. 25.5 application block diagram figure 25-2. application block diagram table 25-1. i/o lines description pin name pin description type sclk 12.288-mhz bit-rate clock (referred as bitclk in ac-link spec) input sdi receiver data (referred as sdata_in in ac-link spec) input sync 48-khz frame indicator and synchronizer output sdo transmitter data (referred as sdata_out in ac-link spec) output ac 97 controller sdo sdi piox ac'97 primary codec sync sclk ac97_reset ac97_sync ac97_sdata_out ac97_bitclk ac-link ac97_sdata_in
442 32054f?avr32?09/09 at32ap7002 25.6 product dependencies 25.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with pio lines. before using the ac97 controller receiver, the pio controller must be configured in order for the ac97c receiver i/o lines to be in ac97 controller peripheral mode. before using the ac97 controller transmitter, the pio controller must be configured in order for the ac97c transmitter i/o lines to be in ac97 controlle r peripheral mode. 25.6.2 power management the ac97 clock is generated by the power manager. before using the ac97, the programmer must ensure that the ac?97 clock is enabled in the power manager. in the ac97 description, master clock (mck) is the clock of the peripheral bus to which the ac97 is connected. it is important that that the mck clock frequency is higher than the sclk (bit clock) clock frequancy as signals that cross the two clock domains are re-synchronized. 25.6.3 interrupt the ac97 interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the ac97. all ac97 controller interrupts can be enabled/dis abled by writing to the ac97 controller inter- rupt enable/disable registers. each pending and unmasked ac97 controller interrupt will assert the interrupt line. the ac97 controller interrupt service routine can get the interrupt source in two steps: ?reading and anding ac97 controller interrupt mask register (imr) and ac97 controller status register (sr). ?reading ac97 controller channel x status register (cxsr).)
443 32054f?avr32?09/09 at32ap7002 25.7 functional description 25.7.1 protocol overview ac-link protocol is a bidirectional, fixed clock rate, serial digital stream. ac-link handles multiple input and output pulse code modulation pcm audio streams, as well as control register accesses employing a time division multiplexed (tdm) scheme that divides each audio frame in 12 outgoing and 12 incoming 20-bit wide data slots. figure 25-3. bidirectional ac-link fr ame with slot assignment slot # ac97fs tag cmd addr cmd data 0 ac97tx (controller output) ac97rx (codec output) pcm l front pcm r front line 1 dac pcm center pcm r surr pcm lfe line 2 dac hset dac io ctrl tag status addr status data pcm left line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status 12 3 4 56 7 8 9 1011 12 pcm l surr pcm right table 25-2. ac-link output slots transmitted from the ac97c controller slot # pin description 0tag 1 command address port 2 command data port 3,4 pcm playback left/right channel 5 modem line 1 output channel 6, 7, 8 pcm center/left surround/right surround 9pcm lfe dac 10 modem line 2 output channel 11 modem handset output channel 12 modem gpio control channel table 25-3. ac-link input slots transmitte d from the ac97c controller slot # pin description 0tag 1 status address port 2 status data port 3,4 pcm playback left/right channel 5 modem line 1 adc 6 dedicated microphone adc 7, 8, 9 vendor reserved 10 modem line 2 adc 11 modem handset input adc 12 modem io status
444 32054f?avr32?09/09 at32ap7002 25.7.2 slot description 25.7.2.1 tag slot the tag slot, or slot 0, is a 16-bit wide slot that always goes at the beginning of an outgoing or incoming frame. within tag slot, the first bit is a global bit that flags the entire frame validity. the next 12 bit positions sampled by the ac97 cont roller indicate which of the corresponding 12 time slots contain valid data. the slot?s last two bits (combined) called codec id, are used to dis- tinguish primary and secondary codec. the 16-bit wide tag slot of the output frame is automatically generated by the ac97 controller according to the transmit request of each channel and to the slotreq from the previous input frame, sent by the ac97 codec, in variable sample rate mode. 25.7.2.2 codec slot 1 the command/status slot is a 20-bit wide slot used to control features, and monitors status for ac97 codec functions. the control interface architecture supports up to sixty-four 16-bit wide read/write registers. only the even registers are currently defined and addressed. slot 1?s bitmap is the following: ?bit 19 is for read/write command, 1= read, 0 = write. ?bits [18:12] are for control register index. ?bits [11:0] are reserved. 25.7.2.3 codec slot 2 slot 2 is a 20-bit wide slot used to carry 16-bit wide ac97 codec control register data. if the cur- rent command port operation is a read, the entire slot time is stuffed with zeros. its bitmap is the following: ?bits [19:4] are the control register data ?bits [3:0] are reserved and stuffed with zeros. 25.7.2.4 data slots [3:12] slots [3:12] are 20-bit wide data slots, they usually carry audio pcm or/and modem i/o data.
445 32054f?avr32?09/09 at32ap7002 25.7.3 ac97 controller channel organization the ac97 controller features a codec channel and 2 logical channels; channel a and channel b. the codec channel controls ac97 codec register s, it enables write and read configuration val- ues in order to bring the ac97 codec to an operating state. the codec channel always runs slot 1 and slot 2 exclusively, in both input and output directions. channel a and channel b transfer data to/from ac97 codec. all audio samples and modem data must transit by these two channels. each slot of the input or the output frame that belongs to this range [3 to 12] can be operated by either channel a or channel b. the slot to cha nnel assignment is configured by two registers: ?ac97 controller input channel assignment register (ica) ?ac97 controller output channel assignment register (oca) the ac97 controller input channel assignment register (ica) configures the input slot to chan- nel assignment. the ac97 controller output channel assignment register (oca) configures the output slot to channel assignment. a slot can be left unassigned to a channel by the ac97 controller. slots 0, 1,and 2 cannot be assigned to channel a or to channel b through the oca and ica registers. the width of sample data, that transit via channel a and channel b varies and can take one of these values; 10, 16, 18 or 20 bits. figure 25-4. logical channel assignment slot # ac97fs tag cmd data 0 ac97tx (controller output) ac97rx (codec output) pcm l front pcm r front line 1 dac pcm center pcm l surr pcm r surr pcm lfe line 2 dac hset dac io ctrl tag status addr status data pcm left pcm right line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status 12 3 4 56 7 8 91011 12 codec channel channel a codec channel channel a ac97c_oca = 0x0000_0209 ac97c_ica = 0x0000_0009 cmd addr
446 32054f?avr32?09/09 at32ap7002 25.7.3.1 ac97 controller setup the following operations must be performed in order to bring the ac97 controller into an operat- ing state: 1. enable the ac97 controller clock in the power manager. 2. turn on ac97 function by enabling the ena bit in ac97 controller mode register (mr). 3. configure the input channel assignment by controlling the ac97 controller input assign- ment register (ica). 4. configure the output channel assignment by controlling the ac97 controller input assignment register (oca). 5. configure sample width for channel a and ch annel b by writing the size bit field in ac97c channel a mode register (camr) and ac97c channel b mode register (cbmr). the application can write 10, 16, 18,or 20-bit wide pcm samples through the ac97 interface and they will be trans ferred into 20-bit wide slots. 6. configure data endianness for channel a and channel b by writing cem bit field in camr and cbmr registers. data on the ac-link are shifted msb first. the application can write little- or big-endian data to the ac97 controller interface. 7. configure the pio controller to drive the reset signal of the external codec. the reset signal must fulfill external ac97 codec timing requirements. 8. enable channel a and/or channel b by writing cen bit field in camr and cbmr registers. 25.7.3.2 transmit operation the application must perform the following steps in order to send data via a channel to the ac97 codec: ?check if previous data has been sent by po lling txrdy flag in the ac97c channel x status register (cxsr). x being one of the 2 channels. ?write data to the ac97 controller channel x transmit holding register (cxthr). once data has been transferred to the channel x shift register, the txrdy flag is automatically set by the ac97 controller which allows the application to start a new write action. the applica- tion can also wait for an interrupt notice associated with txrdy in order to send data. the interrupt remains active until txrdy flag is cleared..
447 32054f?avr32?09/09 at32ap7002 figure 25-5. audio transfer (pcm l front, pcm r front) on channel x the txempty flag in the ac97 controller channel x status register (cxsr) is set when all requested transmissions for a channel have been shifted on the ac-link. the application can either poll txempty flag in cxsr or wait for an interrupt notice associated with the same flag. in most cases, the ac97 controller is embedded in chips that target audio player devices. in such cases, the ac97 controller is exposed to heavy audio transfers. using the polling tech- nique increases processor overhead and may fail to keep the required pace under an operating system. in order to avoid these polling drawbacks, the app lication can perform audio streams by using a dma controller (dmac) connected to both ch annels, which reduces processor overhead and increases performance especially under an operating system. the dmac transmit counter values must be equal to the number of pcm samples to be trans- mitted, each sample goes in one slot. 25.7.3.3 ac97 output frame the ac97 controller outputs a thirteen-slot frame on the ac-link. the first slot (tag slot or slot 0) flags the validity of the entire frame and the validity of each slot; whether a slot carries valid data or not. slots 1 and 2 are used if the application performs control and status monitoring actions on ac97 codec control/status registers. slots [3:12] are used according to the content of the ac97 controller output channel assignment regi ster (oca). if the application performs many transmit requests on a channel, some of the slots associated to this channel or all of them will carry valid data. slot # ac97fs tag cmd addr cmd data 0 ac97tx (controller output) pcm l front pcm r front line 1 dac pcm center pcm l surr pcm r surr pcm lfe line 2 dac hset dac io ctrl 12 3 4 56 7 8 9 1011 12 txrdycx (ac97c_sr) write access to ac97c_thrx pcm l front transfered to the shift register pcm r front transfered to the shift register txempty (ac97c_sr)
448 32054f?avr32?09/09 at32ap7002 25.7.3.4 receive operation the ac97 controller can also receive data from ac97 codec. data is received in the channel?s shift register and then transferred to the ac97 controller channel x read holding register. to read the newly received data, the application must perform the following steps: ?poll rxrdy flag in ac97 controller channel x status register (cxsr). x being one of the 2 channels. ?read data from ac97 controller channel x read holding register. the application can also wait for an interrupt notice in order to read data from cxrhr. the inter- rupt remains active until rxrdy is cleared by reading cxsr. the rxrdy flag in cxsr is set automatically when data is received in the channel x shift regis- ter. data is then shifted to cxrhr. figure 25-6. audio transfer (pcm l front, pcm r front) on channel x if the previously received data has not been read by the application, the new data overwrites the data already waiting in cxrhr, therefore the ovrun flag in cx sr is raised. the application can either poll the ovrun flag in cxsr or wait for an interrupt notice. the interrupt remains active until the ovrun fl ag in cxsr is set. the ac97 controller can also be used in sound recording devices in association with an ac97 codec. the ac97 controller may also be exposed to heavy pcm transfers. the application can use the dmac connected to both channels in order to reduce processor overhead and increase performance especially under an operating system. the dmac receive counter values must be equal to the number of pcm samples to be received. when more than one timeslot is assigned to a channel using dma, the different timeslot sam- ples will be interleaved. 25.7.3.5 ac97 input frame the ac97 controller receives a thirteen slot frame on the ac-link sent by the ac97 codec. the first slot (tag slot or slot 0) fl ags the validity of the entire frame and the validity of each slot; whether a slot carries valid data or not. slots 1 and 2 are used if the application requires status informations from ac97 codec. slots [3:12] are used according to ac97 controller output channel assignment register (ica) content. the ac97 controller will not receive any data from any slot if ica is not assigned to a channel in input. slot # ac97fs 0123 4 56 7 8 9 1011 12 rxrdycx (ac97c_sr) read access to ac97c_rhrx ac97rx (codec output) tag status addr status data pcm left pcm right line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status
449 32054f?avr32?09/09 at32ap7002 25.7.3.6 configuring and using interrupts instead of polling flags in ac97 controller global status register (sr) and in ac97 controller channel x status register (cxsr), the applicatio n can wait for an interr upt notice. the following steps show how to configure and use interrupts correctly: ?set the interruptible flag in ac97 controller channel x mode register (cxmr). ?set the interruptible event and channel event in ac97 controller interrupt enable register (ier). the interrupt handler must read both ac97 controller global status register (sr) and ac97 controller interrupt mask register (imr) and and them to get the real interrupt source. further- more, to get which event was activated, the interrupt handler has to read ac97 controller channel x status register (cxsr), x being the channel whose event triggers the interrupt. the application can disable event interrupts by writing in ac97 controlle r interrupt disable reg- ister (idr). the ac97 controller interrupt mask register (imr) shows which event can trigger an interrupt and which one cannot. 25.7.3.7 endianness endianness can be managed automatically for each channel, except for the codec channel, by writing to channel endianness mode (cem) in cxmr. this enables transferring data on ac-link in little endian format without any additional operation. 25.7.3.8 to transmit a word stored in little endian format on ac-link word to be written in ac97 co ntroller channel x transmit hold ing register (cxthr) (as it is stored in memory or mi croprocessor register). word stored in channel x transmit holding register (ac97c_cxthr) (data to transmit) . data transmitted on appropriate slot: data[19:0] = {byte1[3:0], byte2[7:0], byte3[7:0]}. 25.7.3.9 to transmit a halfword stored in little endian format on ac-link halfword to be written in ac97 controller ch annel x transmit hold ing register (cxthr). halfword stored in ac97 cont roller channel x transmit hold ing register (cxthr) (data to transmit). data emitted on related slot: data[19:0] = {byte1[7:0], byte0[7:0], 0x0}. 31 24 23 16 15 8 7 0 byte3[7:0] byte2[7:0] byte1[7:0] byte0[7:0] 31 24 23 20 19 16 15 8 7 0 ? ? byte1[3:0] byt e2[7:0] byte3[7:0] 31 24 23 16 15 8 7 0 ? ? byte0[7:0] byte1[7:0] 31 24 23 16 15 8 7 0 ? ? byte1[7:0] byte0[7:0]
450 32054f?avr32?09/09 at32ap7002 25.7.3.10 to transmit a10-bit sample stored in little endian format on ac-link halfword to be written in ac97 controller ch annel x transmit hold ing register (cxthr). halfword stored in ac97 cont roller channel x transmit hold ing register (cxthr) (data to transmit). data emitted on related slot: data[19:0] = {byte1[1:0], byte0[7:0], 0x000}. 25.7.3.11 to receive word transfers data received on appropriate slot: data[19:0] = {byte2[3:0], byte1[7:0], byte0[7:0]}. word stored in ac97 co ntroller channel x receiv e holding register (cxrhr) (received data) . data is read from ac97 controller channel x receive holding register (cxrhr) when channel x data size is greater than 16 bits and when little endian mode is enabled (data written to memory). 25.7.3.12 to receive halfword transfers data received on appropriate slot: data[19:0] = {byte1[7:0], byte0[7:0], 0x0 }. halfword stored in ac97 controller channel x receive holding register (cxrhr) (received data). data is read from ac97 controller channel x receive holding register (cxrhr) when data size is equal to 16 bits and when little endian mode is enabled. 25.7.3.13 to receiv e 10-bit samples data received on appropriate slot: data[19:0] = {byte1[1:0], byte0[7:0], 0x000}. halfword stored in ac97 controller channel x receive hold ing register (cxrhr) (received data) 31 24 23 16 15 8 7 0 ? ? byte0[7:0] {0x00, byte1[1:0]} 31 24 23 16 15 10 9 8 7 0 ??? byte1 [1:0] byte0[7:0] 31 24 23 20 19 16 15 8 7 0 ? ? byte2[3:0] byt e1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 byte0[7:0] byte1[7:0] {0x0, byte2[3:0]} 0x00 31 24 23 16 15 8 7 0 ? ? byte1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 ? ? byte0[7:0] byte1[7:0] 31 24 23 16 15 10 9 8 7 0 ??? byte1 [1:0] byte0[7:0]
451 32054f?avr32?09/09 at32ap7002 data read from ac97 controller channel x receive holding regist er (cxrhr) when data size is equal to 10 bits and when little endian mode is enabled. 25.7.4 variable sample rate the problem of variable sample rate can be summarized by a simple example. when passing a 44.1 khz stream across the ac-link, for every 480 audio output frames that are sent across, 441 of them must contain valid sample data. the new ac97 standard approach calls for the addition of ?on-demand? slot request flags. the ac97 codec examines its sample rate control register, the state of its fifos, and the incoming sdata_out tag bits (slot 0) of each output frame and then determines which slotreq bits to set acti ve (low). these bits are passed from the ac97 codec to the ac97 controller in slot 1/slotreq in every audio input frame. each time the ac97 controller sees one or more of the newly defined slot request flags set active (low) in a given audio input frame, it must pass along the next pcm sample for the corresponding slot(s) in the ac-link output frame that immediately follows. the variable sample rate mode is enabled by performing the following steps: ?setting the vra bit in the ac97 controller mode register (mr). ?enable variable rate mode in the ac97 codec by performing a transfer on the codec channel. slot 1 of the input frame is automatically interpreted as slotreq signaling bits. the ac97 con- troller will automatically fill the ac tive slots according to both sl otreq and oca register in the next transmitted frame. 25.7.5 power management 25.7.5.1 powering down the ac-link the ac97 codecs can be placed in low power mo de. the application can bring ac97 codec to a power down state by performing sequential writes to ac97 codec powerdown register . both the bit clock (clock delivered by ac97 codec, sclk) and the input line (sdi) are held at a logic low voltage level. this puts ac 97 codec in power down state while all its registers are still hold- ing current values. without the bit clock, the ac-link is completely in a power down state. the ac97 controller should not attempt to pl ay or capture audio data until it has awakened ac97 codec. to set the ac97 codec in low power mode, t he pr4 bit in the ac97 codec powerdown register (codec address 0x26) must be set to 1. then the primary codec drives both bitclk and sdi to a low logic voltage level. the following operations must be done to put ac97 codec in low power mode: ?disable channel a clearing cen in the camr register. ?disable channel b clearing ce n field in the cbmr register. ?write 0x2680 value in the cothr register. ?poll the txempty flag in cxsr registers for the 2 channels. at this point ac97 code c is in low power mode. 31 24 23 16 15 8 7 3 1 0 ? ? byte0[7:0] 0x00 byte1 [1:0]
452 32054f?avr32?09/09 at32ap7002 25.7.5.2 waking up the ac-link there are two methods to bring the ac-link out of low power mode. regardless of the method, it is always the ac97 controller that performs the wake-up. 25.7.5.3 wake-up tiggered by the ac97 controller the ac97 controller can wake up the ac97 codec by issuing either a cold or a warm reset. the ac97 controller can also wake up the ac97 codec by asserting sync signal, however this action should not be performed for a minimum period of four audio frames following the frame in which the powerdown was issued. 25.7.5.4 wake-up triggered by the ac97 codec this feature is implemented in ac97 modem c odecs that need to report events such as caller- id and wake-up on ring. the ac97 codec can drive sdi signal from low to high level and holding it high until the control- ler issues either a cold or a warm reset. the sdi rising edge is asynchronously (regarding sync) detected by the ac97 controller. if wkup bit is enabled in imr register, an interrupt is triggered that wakes up the ac97 controller which should then immediately issue a cold or a warm reset. if the processor needs to be awakened by an exte rnal event, the sdi signal must be externally connected to the wakeup entry of the system controller. figure 25-7. ac97 power-down/up sequence ac97ck ac97fs tag write to 0x26 data pr4 power down frame sleep state tag write to 0x26 data pr4 wake event warm reset new audio frame tag slot1 slot2 ac97tx ac97rx tag slot1 slot2
453 32054f?avr32?09/09 at32ap7002 25.7.5.5 ac97 codec reset there are three ways to reset an ac97 codec. 25.7.5.6 cold ac97 reset a cold reset is generated by asserting the reset signal low for the minimum specified time (depending on the ac97 codec) and then by de-a sserting reset high. bitclk and sync is reactivated and all ac97 codec registers are set to their default power-on values. transfers on ac-link can resume. the reset signal will be controlled via a pio line. th is is how an applicat ion should perform a cold reset: ?clear and set ena flag in the mr register to reset the ac97 controller ?clear pio line output cont rolling the ac97 reset signal ?wait for the minimum specified time ?set pio line output contro lling the ac97 reset signal bitclk, the clock provided by ac97 codec, is detected by the controller. 25.7.5.7 warm ac97 reset a warm reset reactivates the ac-link without alteri ng ac97 codec registers. a warm reset is sig- naled by driving ac97fx signal high for a minimum of 1us in the absence of bitclk. in the absence of bitclk, ac97fx is treated as an a synchronous (regarding ac97fx) input used to signal a warm reset to ac97 codec. this is the right way to perform a warm reset: ?set wrst in the mr register. ?wait for at least 1us ?clear wrst in the mr register. the application can check that operations have resumed by checking sof flag in the sr regis- ter or wait for an interrupt notice if sof is enabled in imr.
454 32054f?avr32?09/09 at32ap7002 25.8 ac97 controller (a c97c) user interface table 25-4. register mapping offset register register name access reset 0x0-0x4 reserved ? ? ? 0x8 mode register mr read/write 0x0 0xc reserved ? ? ? 0x10 input channel assignment register ica read/write 0x0 0x14 output channel assignment register oca read/write 0x0 0x18-0x1c reserved ? ? ? 0x20 channel a receive holding register carhr read 0x0 0x24 channel a transmit holding register cathr write ? 0x28 channel a status register casr read 0x0 0x2c channel a mode register camr read/write 0x0 0x30 channel b receive holding register cbrhr read 0x0 0x34 channel b transmit holding register cbthr write ? 0x38 channel b status register cbsr read 0x0 0x3c channel b mode register cbmr read/write 0x0 0x40 codec receive holding register corhr read 0x0 0x44 codec transmit holding register cothr write ? 0x48 codec status register cosr read 0x0 0x4c codec mode register comr read/write 0x0 0x50 status register sr read 0x0 0x54 interrupt enable register ier write ? 0x58 interrupt disable register idr write ? 0x5c interrupt mask register imr read 0x0 0x60-0xfb reserved ? ? ?
455 32054f?avr32?09/09 at32ap7002 25.8.1 ac97 controller mode register name: mr access type: read-write ? vra: variable rate (for data slots 3-12) 0: variable rate is inactive. (48 khz only) 1: variable rate is active. ? wrst: warm reset 0: warm reset is inactive. 1: warm reset is active. ? ena: ac97 controller global enable 0: no effect. ac97 function as well as access to other ac97 controller registers are disabled. 1: activates the ac97 function. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????vrawrstena
456 32054f?avr32?09/09 at32ap7002 25.8.2 ac97 controller input channel assignment register register name :ica access type : read/write ? chidx: channel id for the input slot x 31 30 29 28 27 26 25 24 ? ? chid12 chid11 23 22 21 20 19 18 17 16 chid10 chid9 chid8 15 14 13 12 11 10 9 8 chid8 chid7 chid6 chid5 76543210 chid5 chid4 chid3 chidx selected receive channel 0x0 none. no data will be received during this slot x 0x1 channel a data will be received during this slot time. 0x2 channel b data will be received during this slot time
457 32054f?avr32?09/09 at32ap7002 25.8.3 ac97 controller output channel assignment register register name :oca access type : read/write ? chidx: channel id for the output slot x 31 30 29 28 27 26 25 24 ? ? chid12 chid11 23 22 21 20 19 18 17 16 chid10 chid9 chid8 15 14 13 12 11 10 9 8 chid8 chid7 chid6 chid5 76543210 chid5 chid4 chid3 chidx selected transmit channel 0x0 none. no data will be transmitted during this slot x 0x1 channel a data will be transferred during this slot time. 0x2 channel b data will be transferred during this slot time
458 32054f?avr32?09/09 at32ap7002 25.8.4 ac97 controller codec channel receive holding register register name : corhr access type : read-only ?sdata: status data data sent by the codec in the third ac97 input frame slot (slot 2). 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 sdata 76543210 sdata
459 32054f?avr32?09/09 at32ap7002 25.8.5 ac97 controller codec channel transmit holding register register name :cothr access type :write-only ? read: read/write command 0: write operation to the codec r egister indexed by the caddr address. 1: read operation to the codec register indexed by the caddr address. this flag is sent during the second ac97 frame slot ? caddr: codec control register index data sent to the codec in the second ac97 frame slot. ? cdata: command data data sent to the codec in the third ac97 frame slot (slot 2). 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 read caddr 15 14 13 12 11 10 9 8 cdata 76543210 cdata
460 32054f?avr32?09/09 at32ap7002 25.8.6 ac97 controller channel a, channel b receive holding register register name : carhr, cbrhr access type : read-only ? rdata: receive data received data on channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? rdata 15 14 13 12 11 10 9 8 rdata 76543210 rdata
461 32054f?avr32?09/09 at32ap7002 25.8.7 ac97 controller channel a, channel b transmit holding register register name :cathr, cbthr access type :write-only ? tdata: transmit data data to be sent on channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? tdata 15 14 13 12 11 10 9 8 tdata 76543210 tdata
462 32054f?avr32?09/09 at32ap7002 25.8.8 ac97 controller channel a status register register name : casr access type : read-only 25.8.9 ac97 controller channel b status register register name : cbsr access type : read-only 25.8.10 ac97 controller codec channel status register register name : cosr access type : read-only ? txrdy: channel transmit ready 0: data has been loaded in channel transmit register and is waiting to be loaded in the channel transmit shift register. 1: channel transmit register is empty. ? txempty: channel transmit empty 0: data remains in the channel transmit register or is currently transmitted from the channel transmit shift register. 1: data in the channel transmit register have been loaded in the channel transmit shift register and sent to the codec. ? rxrdy: channel receive ready 0: channel receive holding register is empty. 1: data has been received and loaded in channel receive holding register. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? - txempty txrdy
463 32054f?avr32?09/09 at32ap7002 ? ovrun: receive overrun automatically cleared by a processor read operation. 0: no data has been loaded in the channel receive holding register while previous data has not been read since the last read of the status register. 1: data has been loaded in the channel receive holding regi ster while previous data has not yet been read since the last read of the status register.
464 32054f?avr32?09/09 at32ap7002 25.8.11 ac97 controller channel a mode register register name :camr access type : read/write ? dmaen: dma enable 0: disable dma transfers for this channel. 1: enable dma transfers for this channel using dmac. ? cem: channel a endian mode 0: transferring data through channel a is straight forward (big endian). 1: transferring data through channel a from/to a memory is performed with from/to little endian format translation. ? size: channel a data size size encoding note: each time slot in the data phase is 20 bit long. for example, if a 16-bit sample stream is being played to an ac 97 dac, t he first 16 bit positions are presented to the dac msb-justified. they ar e followed by the next four bit positions that the ac97 control ler fills with zeroes. this process ensures that the least significant bits do not introduce any dc biasing, regardless of the impl e- mented dac?s resolution (16-, 18-, or 20-bit). ? cen: channel a enable 0: data transfer is disabled on channel a. 1: data transfer is enabled on channel a. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? dmaen cen ? ? cem size 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy size selected channel 0x0 20 bits 0x1 18bits 0x2 16 bits 0x3 10 bits
465 32054f?avr32?09/09 at32ap7002 25.8.12 ac97 controller channel b mode register register name :cbmr access type : read/write ? dmaen: dma enable 0: disable dma transfers for this channel. 1: enable dma transfers for this channel using dmac. ? cem: channel b endian mode 0: transferring data through channel b is straight forward (big endian). 1: transferring data through channel b from/to a memory is performed with from/to little endian format translation. ? size: channel b data size size encoding note: each time slot in the data phase is 20 bit long. for example, if a 16-bit sample stream is being played to an ac 97 dac, t he first 16 bit positions are presented to the dac msb-justified. they ar e followed by the next four bit positions that the ac97 control ler fills with zeroes. this process ensures that the least significant bits do not introduce any dc biasing, regardless of the impl e- mented dac?s resolution (16-, 18-, or 20-bit). ? cen: channel b enable 0: data transfer is disabled on channel b. 1: data transfer is enabled on channel b. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? dmaen cen ? ? cem size 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy size selected channel 0x0 20 bits 0x1 18bits 0x2 16 bits 0x3 10 bits
466 32054f?avr32?09/09 at32ap7002 25.8.13 ac97 controller codec channel mode register register name : comr access type : read/write ? txrdy: channel transmit ready interrupt enable ? txempty: channel transmit empty interrupt enable ? rxrdy: channel receive ready interrupt enable ? ovrun: receive overrun interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? - txempty txrdy
467 32054f?avr32?09/09 at32ap7002 25.8.14 ac97 controller status register register name :sr access type : read-only wkup and sof flags in sr register are automat ically cleared by a processor read operation. ? sof: start of frame 0: no start of frame has been detected since the last read of the status register. 1: at least one start of frame has been detected since the last read of the status register. ? wkup: wake up detection 0: no wake-up has been detected. 1: at least one rising edge on sdata_in has been asynchr onously detected. that means ac97 codec has notified a wake-up. ? coevt: codec channel event a codec channel event occurs when cosr and comr is not 0. coevt flag is automatically cleared when the channel event condition is cleared. 0: no event on the codec channel has been detected since the last read of the status register. 1: at least one event on th e codec channel is active. ? caevt: channel a event a channel a event occurs when casr and camr is not 0. ca evt flag is automatically cleared when the channel event condition is cleared. 0: no event on the channel a has been detected since the last read of the status register. 1: at least one event on the channel a is active. ? cbevt: channel b event a channel b event occurs when cbsr and cbmr is not 0. cb evt flag is automatically cleared when the channel event condition is cleared. 0: no event on the channel b has been detected since the last read of the status register. 1: at least one event on the channel b is active. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
468 32054f?avr32?09/09 at32ap7002 25.8.15 ac97 controller interrupt enable register register name :ier access type :write-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
469 32054f?avr32?09/09 at32ap7002 25.8.16 ac97 controller interrupt disable register register name :idr access type :write-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
470 32054f?avr32?09/09 at32ap7002 25.8.17 ac97 controller interrupt mask register register name :imr access type : read-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
471 32054f?avr32?09/09 at32ap7002 26. audio bitstream dac (abdac) rev: 1.0.1.1 26.1 features ? digital stereo dac ? oversampled d/a conversion architecture ? oversampling ratio fixed 128x ? fir equalization filter ? digital interpolation filter: comb4 ? 3rd order sigma-delta d/a converters ? digital bitstream outputs ? parallel interface ? connected to dma controller for backgrou nd transfer without cpu intervention 26.2 description the audio bitstream dac converts a 16-bit samp le value to a digital bitstream with an average value proportional to the sample value. two channels are supported, making the audio bit- stream dac particularly suitable for stereo audio. each channel has a pair of complementary digital outputs, dacn and dacn_n, which c an be connected to an external high input imped- ance amplifier. the audio bitstream dac is compromised of two 3rd order sigma delta d/a converter with an oversampling ratio of 128. the samples are upsampl ed with a 4th order sinc interpolation filter (comb4) before being input to the sigmal delta modulator. in order to compensate for the pass band frequency response of the interpolation filter and flatten the overall frequency response, the input to the interpolation filter is first filtered with a simple 3-tap fir filter.the total frequency response of the equalization fir filter and the interpolation filter is given in figure 26-2 on page 483 . the digital output bitstreams from the sigma delta modulators should be low-pass filtered to remove high frequency noise inserted by the modulation process. the output dacn and dacn_n should be as ideal as possible before filtering, to achieve the best snr quality. the output can be connected to a class d amplifier output stage, or it can be low pass filtered and connected to a high input impedance amplifier. a simple 1st order or higher low pass filter that filters all the frequencies above 50 khz should be adequate.
472 32054f?avr32?09/09 at32ap7002 26.3 block diagram figure 26-1. functional block diagram 26.4 pin name list 26.5 product dependencies 26.5.1 i/o lines the output pins used for the output bitstream from the audio bitstream dac may be multiplexed with pio lines. before using the audio bitstream dac, the pio controller must be configured in order for the audio bitstream dac i/o lines to be in audio bitstream dac peripheral mode. 26.5.2 power management the pb-bus clock to the audio bitstream dac is generated by the power manager. before using the audio bitstream dac, the programmer must ensure that the audio bitstream dac clock is enabled in the power manager. table 26-1. i/o lines description pin name pin description type data0 output from audio bitstream dac channel 0 output data1 output from audio bitstream dac channel 1 output datan0 inverted output from audio bitstream dac channel 0 output datan1 inverted output from audio bitstream dac channel 1 output clock generator equalization fir comb (int=128) sigma-delta da-mod equalization fir comb (int=128) sigma-delta da-mod bit_clk bit_out1 bit_out2 clk sample_clk din1[15:0] din2[15:0] audio bitstream dac
473 32054f?avr32?09/09 at32ap7002 26.5.3 clock management the audio bitstream dac needs a separate clock for the d/a conversion operation. this clock should be set up in the generic clock register in the power manager. the frequency of this clock must be 256 times the frequency of the desired samplerate (f s ). for f s =48khz this means that the clock must have a frequency of 12.288mhz. 26.5.4 interrupts the audio bitstream dac interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the audio bitstream dac. all audio bitstream dac interrupts can be enabl ed/disabled by writing to the audio bitstream dac interrupt enable/disable registers. each pending and unmasked audio bitstream dac interrupt will assert the interrup t line. the audio bitstream dac in terrupt service routine can get the interrupt source by reading the interrupt status register. 26.5.5 dma the audio bitstream dac is connected to the dma controller. the dma controller can be pro- grammed to automatically transfer samples to the audio bitstream dac sample data register (sdr) when the audio bitstream dac is ready for new samples. this enables the audio bit- stream dac to operate without any cpu intervention such as polling the interrupt status register (isr) or using interrupts. see the dma controller documentation for details on how to setup dma transfers. 26.6 functional description in order to use the audio bitstream dac the product dependencies given in section 26.5 on page 472 must be resolved. particular attention should be given to the configuration of clocks and i/o lines in order to ensure correct operation of the audio bitstream dac. the audio bitstream dac is enabled by writing the enable bit in the audio bitstream dac control register (cr). the two 16-bit sample values for channel 0 and 1 can then be written to the least and most significant halfword of the sample data register (sdr), respectively. the tx_ready bit in the interrupt status register (isr) will be set whenever the dac is ready to receive a new sample. a new sample value shou ld be written to sdr before 256 dac clock cycles, or an underrun will occur, as indicated by the underrun status flags in isr. isr is cleared when read, or when writing one to the corresponding bits in the interrupt clear register (icr). for interrupt-based operation, the relevant interrupts must be enabled by writing one to the cor- responding bits in the interrupt enable register (ier). interrupts can be disabled by the interrupt disable register (idr), and active interrupts are indicated in the read-only interrupt mask regis- ter (imr). the audio bitstream dac can also be configured for peripheral dma access, in which case only the enable bit in the control register needs to be set in the audio bitstream dac module. 26.6.1 equalization filter the equalization filter is a simple 3-tap fir filter. the purpose of this filter is to compensate for the pass band frequency response of the sinc interpolation filter. the equalization filter makes the pass band response more flat and moves the -3db corner a little higher.
474 32054f?avr32?09/09 at32ap7002 26.6.2 interpolation filter the interpolation filter interpolates from f s to 128f s . this filter is a 4th order cascaded integrator- comb filter, and the basic building blocks of this filter is a comb part and an integrator part. 26.6.3 sigma delta modulator this part is a 3rd order sigma delta modulator co nsisting of three differentiators (delta blocks), three integrators (sigma blocks) and a one bit quantizer. the purpose of the integrators is to shape the noise, so that the noise is reduces in the band of interest and increased at the higher frequencies, where it can be filtered. 26.6.4 data format input data is on two?s complement format.
475 32054f?avr32?09/09 at32ap7002 26.7 audio bitstream dac user interface table 26-2. register mapping offset register register name access reset 0x0 sample data register sdr read/write 0x0 0x4 reserved - - - 0x8 control register cr read/write 0x0 0xc interrupt mask register imr read 0x0 0x10 interrupt enable register ier write - 0x14 interrupt disable register idr write - 0x18 interrupt clear register icr write - 0x1c interrupt status register isr read 0x0
476 32054f?avr32?09/09 at32ap7002 26.7.1 audio bitstream dac sample data register name: sdr access type: read-write ? channel0: sample data for channel 0 signed 16-bit sample data for channel 0. when the swap bit in the dac control register (cr) is set writing to the sample data register (sdr) will cause the values writ ten to channel0 and ch annel1 to be swapped. ? channel1: sample data for channel 1 signed 16-bit sample data for channel 1. when the swap bit in the dac control register (cr) is set writing to the sample data register (sdr) will cause the values writ ten to channel0 and ch annel1 to be swapped. 31 30 29 28 27 26 25 24 channel1 23 22 21 20 19 18 17 16 channel1 15 14 13 12 11 10 9 8 channel0 76543210 channel0
477 32054f?avr32?09/09 at32ap7002 26.7.2 audio bitstream dac control register name: cr access type: read-write ? swap: swap channels 0: the channel0 and channel1 samples will not be swapped when writing the audio bitstream dac sample data register (sdr). 1: the channel0 and channel1 samples will be swapped when writing the audio bitstream da c sample data regis- ter (sdr). ? en: enable audio bitstream dac 0: audio bitstream dac is disabled. 1: audio bitstream dac is enabled. 31 30 29 28 27 26 25 24 enswap------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
478 32054f?avr32?09/09 at32ap7002 26.7.3 audio bitstream dac interrupt mask register name: imr access type: read-only ? underrun: underrun interrupt mask 0: the audio bitstream dac underrun interrupt is disabled. 1: the audio bitstream dac underrun interrupt is enabled. ? tx_ready: tx ready interrupt mask 0: the audio bitstream dac tx ready interrupt is disabled. 1: the audio bitstream dac tx ready interrupt is enabled. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
479 32054f?avr32?09/09 at32ap7002 26.7.4 audio bitstream dac interrupt enable register name: ier access type: write-only ? underrun: underrun interrupt enable 0: no effect. 1: enables the audio bitstream dac underrun interrupt. ? tx_ready: tx ready interrupt enable 0: no effect. 1: enables the audio bitstream dac tx ready interrupt. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
480 32054f?avr32?09/09 at32ap7002 26.7.5 audio bitstream dac interrupt disable register name: idr access type: write-only ? underrun: underrun interrupt disable 0: no effect. 1: disable the audio bitstr eam dac underr un interrupt. ? tx_ready: tx ready interrupt disable 0: no effect. 1: disable the audio bitstr eam dac tx ready interrupt. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
481 32054f?avr32?09/09 at32ap7002 26.7.6 audio bitstream dac interrupt clear register name: icr access type: write-only ? underrun: underrun interrupt clear 0: no effect. 1: clear the audio bitstream dac underrun interrupt. ? tx_ready: tx ready interrupt clear 0: no effect. 1: clear the audio bitstream dac tx ready interrupt. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
482 32054f?avr32?09/09 at32ap7002 26.7.7 audio bitstream dac interrupt status register name: isr access type: read-only ? underrun: underrun interrupt status 0: no audio bitstream dac underrun has occured since the last time isr was read or since reset. 1: at least one audio bitstream dac underrun has occured since the last time isr was read or since reset. ? tx_ready: tx ready interrupt status 0: no audio bitstream dac tx ready has occuredt since the last time isr was read. 1: at least one audio bitstream dac tx ready ha s occuredt since the last time isr was read. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
483 32054f?avr32?09/09 at32ap7002 26.8 frequency response figure 26-2. frequecy response, eq-fir+comb 4 0 1 2 3 4 5 6 7 8 9 10 x 10 4 -6 0 -5 0 -4 0 -3 0 -2 0 -1 0 0 10
484 32054f?avr32?09/09 at32ap7002 27. static memory controller (smc) rev. 1.0.0.3 27.1 features ? 6 chip selects available ? 64-mbytes address space per chip select ? 8-, 16- or 32-bit data bus ? word, halfword, byte transfers ? byte write or byte select lines ? programmable setup, pulse and hold ti me for read signals per chip select ? programmable setup, pulse and hold ti me for write signal s per chip select ? programmable data float time per chip select ? compliant with lcd module ? external wait request ? automatic switch to slow clock mode ? asynchronous read in page mode supporte d: page size ranges from 4 to 32 bytes 27.2 overview the static memory controller (smc) generates the signals that control the access to the exter- nal memory devices or peripheral devices. it has 6 chip selects and a 26-bit address bus. the 32-bit data bus can be configured to interface with 8-, or16-, or 32-bit external devices. separate read and write control signals allow for direct memory and peripheral interfacing. read and write signal waveforms are fully parametrizable. the smc can manage wait requests from external devices to extend the current access. the smc is provided with an automatic slow clock mode. in slow clock mode, it switches from user- programmed waveforms to slow-rate specific waveforms on read and write signals. the smc supports asynchronous burst read in page mode access for page size up to 32 bytes.
485 32054f?avr32?09/09 at32ap7002 27.3 block diagram figure 27-1. smc block diagram 27.4 i/o lines description smc chip select bus matrix power manager clk_smc smc ncs[5:0] nrd nwe0 addr[0] nwe1 addr[1] nwe3 addr[25:2] data[31:0] nwait user interface peripheral bus ncs[5:0] nrd nwr0/nwe a0/nbs0 nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 a[25:2] d[31:0] nwait ebi mux logic i/o controller table 27-1. i/o lines description pin name pin description type active level ncs[5:0] chip select lines output low nrd read signal output low nwr0/nwe write 0/write enable signal output low a0/nbs0 address bit 0/byte 0 select signal output low nwr1/nbs1 write 1/byte 1 select signal output low a1/nwr2/nbs2 address bit 1/write 2/byte 2 select signal output low nwr3/nbs3 write 3/byte 3 select signal output low a[25:2] address bus output d[31:0] data bus input/output nwait external wait signal input low
486 32054f?avr32?09/09 at32ap7002 27.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 27.5.1 i/o lines the smc signals pass through the external bus in terface (ebi) module where they are multi- plexed. the user must first configure the i/o controller to assign the ebi pins corresponding to smc signals to their peripheral function. if the i/o lines of the ebi corresponding to smc signals are not used by the application, they can be us ed for other purposes by the i/o controller. 27.5.2 clocks the clock for the smc bus interface (clk_smc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the smc before disabling the clock, to avoid freezing the smc in an undefined state. 27.6 functional description 27.6.1 application example figure 27-2. smc connections to st atic memory devices 27.6.2 external memory mapping the smc provides up to 26 address lines, a[25:0]. this allows each chip select line to address up to 64mbytes of memory. 128k x 8 sram d0-d7 cs oe we a0-a16 128k x 8 sram d0-d7 cs oe we a0-a16 128k x 8 sram d0-d7 cs oe we a0-a16 128k x 8 sram d0-d7 cs oe we a0-a16 d0-d31 nwr1/nbs1 a0/nbs0 nwr0/nwe a1/nwr2/nbs2 nwr3/nbs3 ncs0 ncs2 ncs1 ncs3 ncs5 ncs4 nrd nrd nrd nrd a2-a25 static memory controller a1/nwr2/nbs2 nwr0/nwe nwr1/nbs1 nwr3/nbs3 d8-d15 d0-d7 d16-d23 d24-d31 a2-a18 a2-a18 a2-a18 a2-a18
487 32054f?avr32?09/09 at32ap7002 if the physical memory device connected on one ch ip select is smaller than 64mbytes, it wraps around and appears to be repeated within this space. the smc correctly handles any valid access to the memory devi ce within the page (see figure 27-3 on page 487 ). a[25:0] is only significant for 8-bit memory, a[25:1 ] is used for 16-bit memory, a[25:2] is used for 32-bit memory. figure 27-3. memory connections for six external devices 27.6.3 connection to external devices 27.6.3.1 data bus width a data bus width of 8, 16, or 32 bits can be se lected for each chip select. this option is con- trolled by the data bus width field in the mo de register (mode.dbw) for the corresponding chip select. figure 27-4 on page 488 shows how to connect a 512k x 8-bit memory on ncs2. figure 27-5 on page 488 shows how to connect a 512k x 16-bit memory on ncs2. figure 27-6 shows two 16- bit memories connected as a single 32-bit memory. 27.6.3.2 byte write or byte select access each chip select with a 16-bit or 32-bit data bus can operate with one of two different types of write access: byte write or byte select access. th is is controlled by the byte access type bit in the mode register (mode.bat) for the corresponding chip select. ncs[0] - ncs[5] nrd nwe a[25:0] d[31:0] smc ncs5 ncs4 ncs3 ncs2 ncs1 ncs0 8 or 16 or 32 memory enable memory enable memory enable memory enable memory enable memory enable output enable write enable a[25:0] d[31:0] or d[15:0] or d[7:0]
488 32054f?avr32?09/09 at32ap7002 figure 27-4. memory connection for an 8-bit data bus figure 27-5. memory connection for a 16-bit data bus figure 27-6. memory connection for a 32-bit data bus ?byte write access the byte write access mode supports one byte write signal per byte of the data bus and a single read signal. note that the smc does not allow boot in byte write access mode. smc a0 nwe nrd ncs[2] a0 write enable output enable memory enable d[7:0] d[7:0] a[18:2] a[18:2] a1 a1 smc nbs0 nwe nrd ncs[2] low byte enable write enable output enable memory enable nbs1 high byte enable d[15:0] d[15:0] a[19:2] a[18:1] a[0] a1 d[31:16] smc nbs0 nwe nrd ncs[2] nbs1 d[15:0] a[20:2] d[31:16] nbs2 nbs3 byte 0 enable write enable output enable memory enable byte 1 enable d[15:0] a[18:0] byte 2 enable byte 3 enable
489 32054f?avr32?09/09 at32ap7002 ? for 16-bit devices: the smc provides nwr0 and nwr1 write signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. one single read signal (nrd) is provided. the byte write access mode is used to connect two 8-bit devices as a 16-bit memory. ? for 32-bit devices: nwr0, nwr1, nwr2 and nwr3, are the write signals of byte0 (lower byte), byte1, byte2, and byte 3 (upper byte) respectively. one single read signal (nrd) is provided. the byte write access is used to connect four 8-bit devices as a 32-bit memory. the byte write optio n is illustrated on figure 27-7 on page 489 . ?byte select access in this mode, read/write operations can be enabled /disabled at a byte level. one byte select line per byte of the data bus is provided. one nrd and one nwe signal control read and write. ? for 16-bit devices: the smc provides nbs0 and nbs1 selection signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. the byte select access is used to connect one 16-bit device. ? for 32-bit devices: nbs0, nbs1, nbs2 and nbs3, are the selection signals of byte0 (lower byte), byte1, byte2, and byte 3 (upper byte) respectively. the byte select access is used to connect two 16-bit devices. figure 27-8 on page 490 shows how to connect tw o 16-bit devices on a 32-bit data bus in byte select access mode, on ncs3. figure 27-7. connection of two 8-bit devices on a 16-bit bus: byte write option ?signal multiplexing depending on the mode.bat bit, only the write si gnals or the byte select signals are used. to save i/os at the external bus interface, control signals at the smc interface are multiplexed. smc a1 nwr0 nrd ncs[3] write enable read enable memory enable nwr1 write enable read enable memory enable d[7:0] d[7:0] d[15:8] d[15:8] a[24:2] a[23:1] a[23:1] a[0] a[0]
490 32054f?avr32?09/09 at32ap7002 for 32-bit devices, bits a0 and a1 are unused. for 16-bit devices, bit a0 of address is unused. when byte select option is selected, nwr1 to nwr3 are unused. when byte write option is selected, nbs0 to nbs3 are unused. figure 27-8. connection of two 16-bit data bus on a 32-bit data bus: byte select option smc nwe nrd ncs[3] write enable read enable memory enable nbs0 d[15:0] d[15:0] d[31:16] a[25:2] a[23:0] write enable read enable memory enable d[31:16] a[23:0] low byte enable high byte enable low byte enable high byte enable nbs1 nbs2 nbs3 table 27-2. smc multiplexed signal translation signal name 32-bit bus 16-bit bus 8-bit bus device type 1 x 32-bit 2 x 16-bit 4 x 8-bit 1 x 16-bit 2 x 8-bit 1 x 8-bit byte access type (bat) byte select byte select byte write byte select byte write nbs0_a0 nbs0 nbs0 nbs0 a0 nwe_nwr0 nwe nwe nwr0 nwe nwr0 nwe nbs1_nwr1 nbs1 nbs1 nwr1 nbs1 nwr1 nbs2_nwr2_a1 nbs2 nbs2 nwr2 a1 a1 a1 nbs3_nwr3 nbs3 nbs3 nwr3
491 32054f?avr32?09/09 at32ap7002 27.6.4 standard read and write protocols in the following sections, the byte access type is not considered. byte select lines (nbs0 to nbs3) always have the same timing as the address bus (a). nwe represents either the nwe signal in byte select access type or one of the byte write lines (nwr0 to nwr3) in byte write access type. nwr0 to nwr3 have the same ti mings and protocol as nwe. in the same way, ncs represents one of the ncs[0..5] chip select lines. 27.6.4.1 read waveforms the read cycle is shown on figure 27-9 on page 491 . the read cycle starts with the address setting on the memory address bus, i.e.: {a[25:2], a1, a0} for 8-bit devices {a[25:2], a1} for 16-bit devices a[25:2] for 32-bit devices. figure 27-9. standard read cycle ?nrd waveform the nrd signal is characterized by a se tup timing, a pulse width, and a hold timing. 1. nrdsetup: the nrd setup time is defined as the setup of address before the nrd fall- ing edge. 2. nrdpulse: the nrd pulse length is the time between nrd falling edge and nrd rising edge. a[25:2] clk_smc nbs0, nbs1, a0, a1 nrd ncs d[15:0] ncsrdsetup nrdsetup nrdpulse ncsrdpulse nrdcycle nrdhold ncsrdhold
492 32054f?avr32?09/09 at32ap7002 3. nrdhold: the nrd hold time is defined as the hold time of address after the nrd ris- ing edge. ?ncs waveform similarly, the ncs signal can be divided into a setup time, pulse length and hold time. 1. ncsrdsetup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncsrdpulse: the ncs pulse length is t he time between ncs falling edge and ncs rising edge. 3. ncsrdhold: the ncs hold time is defined as the hold time of address after the ncs rising edge. ?read cycle the nrdcycle time is defined as the total duration of the read cycle, i.e., from the time where address is set on the address bus to the point where address may change. the total read cycle time is equal to: similarly, all nrd and ncs timings are defined separately for each chip select as an integer number of clk_smc cycles. to ensure that the nrd and ncs timings ar e coherent, the user must define the total read cycle instead of the hold timing. nrdcycle implicitly defines the nrd hold time and ncs hold time as: and, ?null delay setup and hold if null setup and hold parame ters are programmed for nrd and/or ncs, nrd and ncs remain active continuously in case of consecutive read cycles in the same memory (see figure 27-10 on page 493 ). nrdcycle nrdsetup nrdpulse nrdhold ++ = nrdcycle ncsrdsetup ncsrdpulse ncsrdhold ++ = nrdhold nrdcycle nrdsetup ? nrdpulse ? = ncsrdhold nrdcycle ncsrdsetup ? ncsrdpulse ? =
493 32054f?avr32?09/09 at32ap7002 figure 27-10. no setup, no hold on nrd, and ncs read signals ?null pulse programming null pulse is not permitted. pulse must be at least written to one. a null value leads to unpredictable behavior. 27.6.4.2 read mode as ncs and nrd waveforms are defined independently of one other, the smc needs to know when the read data is available on the data bus. the smc does not compare ncs and nrd tim- ings to know which signal rises first. the read mode bit in the mode register (mode.readmode) of the corresponding chip se lect indicates which signal of nrd and ncs controls the read operation. ?read is controlled by nrd (mode.readmode = 1) figure 27-11 on page 494 shows the waveforms of a read operation of a typical asynchronous ram. the read data is available t pacc after the falling edge of nrd, and turns to ?z? after the ris- ing edge of nrd. in this case, the mode.readmode bit must be written to one (read is controlled by nrd), to indicate th at data is availabl e with the rising edge of nrd. the smc sam- ples the read data internally on the rising ed ge of clk_smc that generates the rising edge of nrd, whatever the programmed waveform of ncs may be. clk_smc a[25:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] nrdsetup nrdpulse ncsrdpulse nrdcycle nrdcycle ncsrdpulse ncsrdpulse nrdpulse nrdcycle
494 32054f?avr32?09/09 at32ap7002 figure 27-11. readmode = 1: data is sampled by smc before the rising edge of nrd ?read is controlled by ncs (mode.readmode = 0) figure 27-12 on page 495 shows the typical read cycle of an lcd module. the read data is valid t pacc after the falling edge of the ncs signal and remains valid until the rising edge of ncs. data must be sampled when ncs is raised. in that case, the mode.readmode bit must be written to zero (read is controlled by ncs): the smc internally samples the data on the rising edge of cml_smc that generates the rising edge of ncs, whatever the programmed waveform of nrd may be. clk_smc a[25:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc data sampling
495 32054f?avr32?09/09 at32ap7002 figure 27-12. readmode = 0: data is sampled by smc before the rising edge of ncs 27.6.4.3 write waveforms the write protocol is similar to the read protocol. it is depicted in figure 27-13 on page 496 . the write cycle starts with the address setting on the memory address bus. ?nwe waveforms the nwe signal is characterized by a setu p timing, a pulse width and a hold timing. 1. nwesetup: the nwe setup time is defined as the setup of address and data before the nwe falling edge. 2. nwepulse: the nwe pulse length is the time between nwe falling edge and nwe ris- ing edge. 3. nwehold: the nwe hold time is defined as the hold time of address and data after the nwe rising edge. the nwe waveforms apply to all byte-write lines in byte write access mode: nwr0 to nwr3. 27.6.4.4 ncs waveforms the ncs signal waveforms in write operation are not the same that those applied in read opera- tions, but are separately defined. 1. ncswrsetup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncswrpulse: the ncs pulse length is the time between ncs falling edge and ncs rising edge; 3. ncswrhold: the ncs hold time is defined as the hold time of address after the ncs rising edge. clk_smc a[25:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc data sampling
496 32054f?avr32?09/09 at32ap7002 figure 27-13. write cycle ?write cycle the write cycle time is defined as the total duration of the write cycle, that is, from the time where address is set on the address bus to the point where address may change. the total write cycle time is equal to: similarly, all nwe and ncs (write) timings are defined separately for each chip select as an integer num- ber of clk_smc cycles. to ensure that the nwe and ncs timings are coherent, the user must define the total write cycle instead of the hold timi ng. this implicitly defines the nwe hold time and ncs (write) hold times as: and, clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe ncs nwesetup nwepulse ncswrpulse ncswrsetup nwecycle nwehold ncswrhold nwecycle nwesetup nwepulse nwehold ++ = nwecycle ncswrsetup ncswrpulse ncswrhold ++ = nwehold nwecycle nwesetup ? nwepulse ? = ncswrhold nwecycle ncswrsetup ? ncswrpulse ? =
497 32054f?avr32?09/09 at32ap7002 ?null delay setup and hold if null setup parameters are programmed for nwe and/or ncs, nwe and/or ncs remain active continuously in case of consecutive wr ite cycles in the same memory (see figure 27-14 on page 497 ). however, for devices that perform write operations on the rising edge of nwe or ncs, such as sram, either a setup or a hold must be programmed. figure 27-14. null setup and hold values of ncs and nwe in write cycle ?null pulse programming null pulse is not permitted. pulse must be at least written to one. a null value leads to unpredictable behavior. 27.6.4.5 write mode the write mode bit in the mode register (mode.writemode) of the corresponding chip select indicates which signal controls the write operation. ?write is controlled by nwe (mode.writemode = 1) figure 27-15 on page 498 shows the waveforms of a writ e operation with mode.writemode equal to one. the data is put on the bus during the pulse and hold steps of the nwe signal. the internal data buffers are turned out after the nwesetup time, and until the end of the write cycle, regardless of the programmed waveform on ncs. clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe, nwe0, nwe1 ncs nwesetup nwepulse ncswrpulse ncswrsetup nwecycle d[15:0] nwecycle nwepulse ncswrpulse nwecycle
498 32054f?avr32?09/09 at32ap7002 figure 27-15. writemode = 1. the write operation is controlled by nwe ?write is controlled by ncs (mode.writemode = 0) figure 27-16 on page 498 shows the waveforms of a writ e operation with mode.writemode written to zero. the data is put on the bus during the pulse and hold steps of the ncs signal. the internal data buffers are turned out after the ncswrsetup time, and until the end of the write cycle, regardless of the programmed waveform on nwe. figure 27-16. writemode = 0. the write operation is controlled by ncs clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe, nwr0, nwr1 ncs d[15:0] clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe, nwr0, nwr1 ncs d[15:0]
499 32054f?avr32?09/09 at32ap7002 27.6.4.6 coding timing parameters all timing parameters are defined for one chip select and are grouped together in one register according to their type. the setup register (setup) groups the definition of all setup parameters: ? nrdsetup, ncsrdsetup, nwesetup, and ncswrsetup. the pulse register (pulse) groups the definition of all pulse parameters: ? nrdpulse, ncsrdpulse, nwepulse, and ncswrpulse. the cycle register (cycle) groups the definition of all cycle parameters: ? nrdcycle, nwecycle. table 27-3 on page 499 shows how the timing parameters are coded and their permitted range. 27.6.4.7 usage restriction the smc does not check the validity of the user-programmed parameters. if the sum of setup and pulse parameters is larger than the corresponding cycle parameter, this leads to unpre- dictable behavior of the smc. for read operations: null but positive setup and hold of address and nrd and/or ncs can not be guaranteed at the memory interface because of the propagation dela y of theses signals through external logic and pads. if positive setup and hold values must be verified, then it is strictly recommended to pro- gram non-null values so as to cover possible skews between address, ncs and nrd signals. for write operations: if a null hold value is programmed on nwe, the smc can guarantee a positive hold of address, byte select lines, and ncs signal after the rising edge of nwe. this is true if the mode.write- mode bit is written to one. see section 27.6.5.2 . for read and write operations: a null value for pulse parameters is forbidden and may lead to unpredictable behavior. in read and write cycles, the setup and hold time parameters are defined in reference to the address bus. for external devices that require setup and hold time between ncs and nrd sig- nals (read), or between ncs and nwe signals (write), these setup and hold times must be converted into setup and hold times in reference to the address bus. table 27-3. coding and range of timing parameters coded value number of bits effective value permitted range coded value effective value setup [5:0] 6 128 x setup[5] + setup[4:0] 0 value 31 128 value 128+31 pulse [6:0] 7 256 x pulse[6] + pulse[5:0] 0 value 63 256 value 256+63 cycle [8:0] 9 256 x cycle[ 8:7] + cycle[6:0] 0 value 127 256 value 256+127 512 value 512+127 768 value 768+127
500 32054f?avr32?09/09 at32ap7002 27.6.5 automatic wait states under certain circumstances, the smc automatica lly inserts idle cycles between accesses to avoid bus contention or operation conflict. 27.6.5.1 chip sele ct wait states the smc always inserts an idle cycle between two transfers on separate ch ip selects. this idle cycle ensures that there is no bus contention bet ween the deactivation of one device and the activation of the next one. during chip select wait state, all control li nes are turned inactive: nbs0 to nbs3, nwr0 to nwr3, ncs[0..5], nrd lines are all set to high level. figure 27-17 on page 500 illustrates a chip select wait stat e between access on chip select 0 (ncs0) and chip select 2 (ncs2). figure 27-17. chip select wait state between a read access on ncs0 and a write access on ncs2 27.6.5.2 early read wait state in some cases, the smc inserts a wait state cycle between a write access and a read access to allow time for the write cycle to end before the subsequent read cycle begins. this wait state is not generated in addition to a chip select wait state. the early read cycle thus only occurs between a write and read access to the same memory device (same chip select). clk_smc a[25:2] nbs1, , a1 nrd nwe ncs0 ncs2 d[15:0] nrdcycle read to write wait state chip select wait state nwecycle
501 32054f?avr32?09/09 at32ap7002 an early read wait state is automatically inserted if at least one of the following conditions is valid: ? if the write controlling signal has no hold time and the read controlling signal has no setup time ( figure 27-18 on page 501 ). ? in ncs write controlled mode (m ode.writemode = 0), if there is no hold timing on the ncs signal and the ncsrdsetup parameter is set to zero, regardless of the read mode ( figure 27-19 on page 502 ). the write operation must end with a ncs rising edge. without an early read wait state, the write operation could not complete properly. ? in nwe controlled mode (mode.writemode = 1) and if there is no hold timing (nwehold = 0), the feedback of the write control signal is used to control address, data, chip select, and byte select lines. if the external write control signal is not inactivated as expected due to load capacitances, an early read wait state is insert ed and address, data and control signals are maintained one more cycle. see figure 27-20 on page 503 . figure 27-18. early read wait state: write with no hold followed by read with no setup. clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe nrd d[15:0] no hold no setup read cycle early read wait state write cycle
502 32054f?avr32?09/09 at32ap7002 figure 27-19. early read wait state: ncs controlled write with no hold followed by a read with no setup. clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe nrd d[15:0] no hold no setup read cycle (readmode=0 or readmode=1) early read wait state write cycle (writemode=0)
503 32054f?avr32?09/09 at32ap7002 figure 27-20. early read wait state: nwe-controlled write with no hold followed by a read with one set-up cycle. 27.6.5.3 reload user configuration wait state the user may change any of the configuration parameters by writing the smc user interface. when detecting that a new user configuration has been written in the user interface, the smc inserts a wait state before starting the next access. the so called ?reload user configuration wait state? is used by the smc to load the new set of parameters to apply to next accesses. the reload configuration wa it state is not applied in addition to the chip select wait state. if accesses before and after reprogramming the user interface are made to different devices (dif- ferent chip selects), then one single chip select wait state is applied. on the other hand, if accesses before and after writing the user interface are made to the same device, a reload configuration wait state is inserted, even if the change does not concern the cur- rent chip select. ?user procedure to insert a reload configuration wait state, the smc detects a write access to any mode register of the user interface. if the user only modifies timing registers (setup, pulse, cycle regis- ters) in the user interface, he must validate th e modification by writing the mode register, even if no change was made on the mode parameters. clk_smc a[25:2] nbs0, nbs1, a0, a1 internal write controlling signal external write controlling signal(nwe) nrd d[15:0] no hold read setup=1 write cycle (writemode = 1) early read wait state read cycle (readmode=0 or readmode=1)
504 32054f?avr32?09/09 at32ap7002 ?slow clock mode transition a reload configuration wait state is also inserted when the slow clock mode is entered or exited, after the end of the current transfer (see section 27.6.8 ). 27.6.5.4 read to write wait state due to an internal mechanism, a wait cycle is always inserted between consecutive read and write smc accesses. this wait cycle is referred to as a read to write wait stat e in this document. this wait cycle is applied in add ition to chip select and reload user configuration wait states when they are to be inserted. see figure 27-17 on page 500 . 27.6.6 data float wait states some memory devices are slow to release the exte rnal bus. for such devices, it is necessary to add wait states (data float wait states) after a read access: ? before starting a read access to a different external memory. ? before starting a write access to the same device or to a different external one. the data float output time (t df ) for each external memory device is programmed in the data float time field of the mode register (mod e.tdfcycles) for the corresponding chip select. the value of mode.tdfcycles indicates the number of data float wait cycles (between 0 and 15) before the external device releases the bus, and represents the time allowed for the data output to go to high impedance after the memory is disabled. data float wait states do not delay internal memory accesses. hence, a single access to an external memory with long t df will not slow down the executio n of a program from internal memory. the data float wait states management depends on the mode.readmode bit and the tdf optimization bit of the mode register (mode. tdfmode) for the corresponding chip select. 27.6.6.1 read mode writing a one to the mode.readmo de bit indicates to the smc that the nrd signal is respon- sible for turning off the tri-state buffers of the external memory device. the data float period then begins after the rising edge of the nrd signal and lasts mode.tdfcycles cycles of the clk_smc clock. when the read operation is controlled by the ncs signal (mode.readmode = 0), the mode.tdfcycles field gives the number of clk_smc cycles during which the data bus remains busy after the rising edge of ncs. figure 27-21 on page 505 illustrates the data float period in nrd-controlled mode (mode.readmode =1), assuming a data float period of two cycles (mode.tdfcycles = 2). figure 27-22 on page 505 shows the read operation when controlled by ncs (mode.read- mode = 0) and the mode.tdfcycles field equals to three.
505 32054f?avr32?09/09 at32ap7002 figure 27-21. tdf period in nrd controlled read access (tdfcycles = 2) figure 27-22. tdf period in ncs controlled r ead operation (tdfcycles = 3) clk_smc a[25:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc nrd controlled read operation tdf = 2 clock cycles clk_smc a[25:2] nbs0, nbs1, a0, a1 nrd ncs d[15:0] t pacc ncs controlled read operation tdf = 3 clock cycles
506 32054f?avr32?09/09 at32ap7002 27.6.6.2 tdf optimization enabled (mode.tdfmode = 1) when the mode.tdfmode bit is written to one (tdf optimization is enabled), the smc takes advantage of the setup period of the next access to optimize the number of wait states cycle to insert. figure 27-23 on page 506 shows a read access controlled by nrd, followed by a write access controlled by nwe, on chip select 0. chip select 0 has been programmed with: nrdhold = 4; readmode = 1 (nrd controlled) nwesetup = 3; writemode = 1 (nwe controlled) tdfcycles = 6; tdfmode = 1 (optimization enabled). figure 27-23. tdf optimization: no tdf wait states are inserted if the tdf period is over when the next access begins 27.6.6.3 tdf optimization disabled (mode.tdfmode = 0) when optimization is disabled, data float wait states are inserted at the end of the read transfer, so that the data float period is ended when the second access begins. if the hold period of the read1 controlling signal ov erlaps the data float period, no additional data float wait states will be inserted. figure 27-24 on page 507 , figure 27-25 on page 507 and figure 27-26 on page 508 illustrate the cases: ? read access followed by a read access on another chip select. clk_smc a[25:2] nrd nwe ncs0 d[15:0] read access on ncs0 (nrd controlled) read to write wait state write access on ncs0 (nwe controlled) tdfcycles = 6 nwesetup = 3 nrdhold = 4
507 32054f?avr32?09/09 at32ap7002 ? read access followed by a write access on another chip select. ? read access followed by a write access on the same chip select. with no tdf optimization. figure 27-24. tdf optimization disabled (mode.tdfmode = 0). tdf wait states between two read accesses on dif- ferent chip selects. figure 27-25. tdf optimization disabled (mode.tdfmode= 0). tdf wait states between a read and a write access on different chip selects. clk_smc a[25:2] nbs0, nbs1, a0, a1 read1 controlling signal(nrd) read2 controlling signal(nrd) d[15:0] read1 hold = 1 read1 cycle tdfcycles = 6 chip select wait state 5 tdf wait states tdfcycles = 6 read2 setup = 1 read 2 cycle tdfmode=0 (optimization disabled) clk_smc a[25:2] nbs0, nbs1, a0, a1 read1 controlling signal(nrd) write2 controlling signal(nwe) d[15:0] read1 cycle tdfcycles = 4 chip select wait state read1 hold = 1 tdfcycles = 4 read to write wait state 2 tdf wait states write2 setup = 1 write 2 cycle tdfmode=0 (optimization disabled)
508 32054f?avr32?09/09 at32ap7002 figure 27-26. tdf optimization disabled (mode.tdfmode = 0). tdf wa it states between read and write accesses on the same chip select. 27.6.7 external wait any access can be extended by an external device using the nw ait input signal of the smc. the external wait mode field of the mode register (mode.exnwmode) on the corresponding chip select must be written to either two (frozen mode) or three (ready mode). when the mode.exnwmode field is written to zero (disabled), the nwait signal is simply ignored on the corresponding chip select. the nwait signal delays the read or write operation in regards to the read or write controlling signal, depending on the read and wr ite modes of the corresponding chip select. 27.6.7.1 restriction when one of the mode.exnwmode is enabled, it is mandatory to program at least one hold cycle for the read/write controlling signal. for that reason, the nwait signal cannot be used in page mode ( section 27.6.9 ), or in slow clock mode ( section 27.6.8 ). the nwait signal is assumed to be a response of the external device to the read/write request of the smc. then nwait is examined by the smc only in the pulse state of the read or write controlling signal. the assertion of the nwait signal outside th e expected period has no impact on smc behavior. 27.6.7.2 frozen mode when the external device asserts the nwait signal (active low), and after internal synchroniza- tion of this signal, the smc state is frozen, i.e., smc internal counters are frozen, and all control signals remain unchanged. when the synchroniz ed nwait signal is deasserted, the smc com- pletes the access, resuming the access from the point where it was stopped. see figure 27-27 on page 509 . this mode must be selected when the external device uses the nwait signal to delay the access and to freeze the smc. clk_smc a[25:2] nbs0, nbs1, a0, a1 read1 controlling signal(nrd) write2 controlling signal(nwe) d[15:0] read1 hold = 1 tdfcycles = 5 read1 cycle tdfcycles = 5 read to write wait state 4 tdf wait states write2 setup = 1 write 2 cycle tdfmode=0 (optimization disabled)
509 32054f?avr32?09/09 at32ap7002 the assertion of the nwait sign al outside the expected period is ignored as illustrated in figure 27-28 on page 510 . figure 27-27. write access with nwait assertion in frozen mode (mode.exnwmode = 2). clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe ncs d[15:0] 654 4 3 3 2 21 1 2 1 22 1 0 0 frozen state nwait internally synchronized nwait signal write cycle exnwmode = 2 (frozen) writemode = 1 (nwe controlled) nwepulse = 5 ncswrpulse = 7
510 32054f?avr32?09/09 at32ap7002 figure 27-28. read access with nwait assertion in frozen mode (mode.exnwmode = 2). clk_smc a[25:2] nbs0, nbs1, a0, a1 ncs nrd nwait internally synchronized nwait signal exnwmode = 2 (frozen) readmode = 0 (ncs controlled) nrdpulse = 2, nrdhold = 6 ncsrdpulse = 5, ncsrdhold = 3 read cycle assertion is ignored 43 2 10 22 1 0 5 55 4 3 2 21 10 0 frozen state
511 32054f?avr32?09/09 at32ap7002 27.6.7.3 ready mode in ready mode (mode.exnwmode = 3), the smc behaves differently. normally, the smc begins the access by down counting the setup and pulse counters of the read/write controlling signal. in the last cycle of the pulse phase, the resynchronized nwait signal is examined. if asserted, the smc suspends the access as shown in figure 27-29 on page 511 and figure 27-30 on page 512 . after deassertion, the access is completed: the hold step of the access is performed. this mode must be selected when the external de vice uses deassertion of the nwait signal to indicate its ability to complete the read or write operation. if the nwait signal is deasserted before the end of the pulse, or asserted after the end of the pulse of the controlling read/write signal, it has no impact on the access length as shown in fig- ure 27-30 on page 512 . figure 27-29. nwait assertion in write access: ready mode (mode.exnwmode = 3). clk_smc a[25:2] nbs0, nbs1, a0, a1 nwe ncs d[15:0] 654 4 3 3 2 21 0 1 0 11 0 frozen state nwait internally synchronized nwait signal w rite cycle exnwmode = 3 (ready mode) writemode = 1 (nwe_controlled) nwepulse = 5 ncswrpulse = 7 0
512 32054f?avr32?09/09 at32ap7002 figure 27-30. nwait assertion in read access : ready mode (exnwmode = 3). clk_smc a[25:2] nbs0, nbs1, a0, a1 ncs nrd 6 6 5 5 4 4 3 2 3 1 21 0 nwait internally synchronized nwait signal read cycle exnwmode = 3 (ready mode) readmode = 0 (ncs_controlled) nrdpulse = 7 ncsrdpulse = 7 1 0 0 assertion is ignored assertion is ignored wait state
513 32054f?avr32?09/09 at32ap7002 27.6.7.4 nwait latency and read/write timings there may be a latency between the assertion of the read/w rite controlling signal and the asser- tion of the nwait signal by the device. t he programmed pulse length of the read/write controlling signal must be at least equal to this latency plus the two cy cles of resynchronization plus one cycle. otherwise, the smc may enter the hold state of the access without detecting the nwait signal assertion. this is true in frozen mode as well as in ready mode. th is is illustrated on figure 27-31 on page 513 . when the mode.exnwmode field is enabled (ready or frozen), the user must program a pulse length of the read and write controlling si gnal of at least: figure 27-31. nwait latency minimal pulse length nwait latency 2 synchronization cycles 1 cycle ++ = wait state 0 1 2 3 4 clk_smc a[25:2] nbs0, nbs1, a0, a1 nrd nwait nternally synchronized nwait signal minimal pulse length 0 0 nwait latency 2 cycle resynchronization read cycle exnwmode = 2 or 3 readmode = 1 (nrd controlled) nrdpulse = 5
514 32054f?avr32?09/09 at32ap7002 27.6.8 slow clock mode the smc is able to automatically apply a set of ?slow clock mode? read/write waveforms when an internal signal driven by the smc?s po wer management controller is asserted because clk_smc has been turned to a very slow clock rate (typically 32 khz clock rate). in this mode, the user-programmed waveforms are ignored and the slow clock mode waveforms are applied. this mode is provided so as to avoid reprogram ming the user interface with appropriate wave- forms at very slow clock rate. when activated, the slow mode is active on all chip selects. 27.6.8.1 slow clock mode waveforms figure 27-32 on page 514 illustrates the read and write operations in slow clock mode. they are valid on all chip selects. table 27-4 on page 514 indicates the value of read and write parame- ters in slow clock mode. figure 27-32. read and write cycles in slow clock mode clk_smc a[25:2] nbs0, nbs1, a0, a1 ncs nwe nwecycles = 3 slow clock mode write 1 1 1 clk_smc a[25:2] nbs0, nbs1, a0, a1 ncs nrd slow clock mode read nrdcycles = 2 1 1 table 27-4. read and write timing parameters in slow clock mode read parameters duration (cycles) write parameters duration (cycles) nrdsetup 1 nwesetup 1 nrdpulse 1 nwepulse 1 ncsrdsetup 0 ncswrsetup 0 ncsrdpulse 2 ncswrpulse 3 nrdcycle 2 nwecycle 3
515 32054f?avr32?09/09 at32ap7002 27.6.8.2 switching from (to) slow clock mode to (from) normal mode when switching from slow clock mode to the nor mal mode, the current slow clock mode transfer is completed at high clock rate, with the set of slow clock mode parameters. see figure 27-33 on page 515 . the external device may not be fast enough to support such timings. figure 27-34 on page 516 illustrates the recommended procedur e to properly switch from one mode to the other. figure 27-33. clock rate transition occurs while the smc is performing a write operation clk_smc a[25:2] nbs0, nbs1, a0, a1 ncs nwe slow clock mode internal signal from pm this write cycle finishes with the slow clock mode set of parameters after the clock rate transition nwecycle = 3 slow clock mode write slow clock mode write 11 1 1 1 1 2 3 2 nwecycle = 7 normal mode write slow clock mode transition is detected: reload configuration wait state
516 32054f?avr32?09/09 at32ap7002 figure 27-34. recommended procedure to switch from slow clock mo de to normal mode or from normal mode to slow clock mode 27.6.9 asynchronous page mode the smc supports asynchronous burst reads in page mode, providing that the page mode enabled bit is written to one in the mode register (mode.pmen). the page size must be con- figured in the page size field in the mode register (mode.ps) to 4, 8, 16, or 32 bytes. the page defines a set of consecutive bytes into memory. a 4-byte page (resp. 8-, 16-, 32-byte page) is always aligned to 4-byte boundaries (resp. 8-, 16-, 32-byte boundaries) of memory. the msb of data address defines the address of the page in memory, the lsb of address define the address of the data in the page as detailed in table 27-5 on page 516 . with page mode memory devices, the first access to one page (t pa ) takes longer than the subse- quent accesses to the page (t sa ) as shown in figure 27-35 on page 517 . when in page mode, the smc enables the user to define different r ead timings for the first access within one page, and next accesses within the page. notes: 1. a denotes the address bus of the memory device 2. for 16-bit devices, the bit 0 of address is ignored. for 32-bit devices, bits [1:0] are ignored. 27.6.9.1 protocol and timings in page mode figure 27-35 on page 517 shows the nrd and ncs timings in page mode access. clk_smc slow clock mode internal signal from pm a[25:2] nbs0, nbs1, a0, a1 nwe ncs 11 slow clock mode write 23 2 idle state reload configuration wait state normal mode write 1 table 27-5. page address and data address within a page page size page address (1) data address in the page (2) 4 bytes a[25:2] a[1:0] 8 bytes a[25:3] a[2:0] 16 bytes a[25:4] a[3:0] 32 bytes a[25:5] a[4:0]
517 32054f?avr32?09/09 at32ap7002 figure 27-35. page mode read protocol (address msb and lsb are defined in table 27-5 on page 516 ) the nrd and ncs signals are held low during all read transfers, whatever the programmed val- ues of the setup and hold timings in the us er interface may be. moreover, the nrd and ncs timings are identical. the pulse length of the first access to the page is defined with the pulse.ncsrdpulse field value. the pulse length of subsequent accesses within the page are defined using the pulse.nrdpulse field value. in page mode, the programming of the read timings is described in table 27-6 on page 517 : the smc does not check the coherency of timi ngs. it will always apply the ncsrdpulse tim- ings as page access timing (t pa ) and the nrdpulse for accesses to the page (t sa ), even if the programmed value for t pa is shorter than the programmed value for t sa . 27.6.9.2 byte access type in page mode the byte access type configuration remains active in page mode. for 16-bit or 32-bit page mode devices that require byte select ion signals, configure the mode.bat bit to zero (byte select access type). clk_smc a[msb] a[lsb] ncs nrd d[15:0] t pa ncsrdpulse t sa nrdpulse nrdpulse t sa table 27-6. programming of read timings in page mode parameter value definition readmode ?x? no impact ncsrdsetup ?x? no impact ncsrdpulse t pa access time of first access to the page nrdsetup ?x? no impact nrdpulse t sa access time of subsequent accesses in the page nrdcycle ?x? no impact
518 32054f?avr32?09/09 at32ap7002 27.6.9.3 page mode restriction the page mode is not compatible with the use of the nwait signal. using the page mode and the nwait signal may lead to unpredictable behavior. 27.6.9.4 sequential and non-sequential accesses if the chip select and the msb of addresses as defined in table 27-5 on page 516 are identical, then the current access lies in the same page as the previous one, and no page break occurs. using this information, all data within the same page, sequential or not sequential, are accessed with a minimum access time (t sa ). figure 27-36 on page 518 illustrates access to an 8-bit mem- ory device in page mode, with 8-byte pages. access to d1 causes a page access with a long access time (t pa ). accesses to d3 and d7, though they are not sequential accesses, only require a short access time (t sa ). if the msb of addresses are different, the smc performs the access of a new page. in the same way, if the chip select is diffe rent from the previous access, a page break occurs. if two sequen- tial accesses are made to the page mode memory , but separated by an other internal or external peripheral access, a page break occurs on the second access because the chip select of the device was deasserted between both accesses. figure 27-36. access to non-sequential data within the same page clk_smc a[25:3] a[2], a1, a0 ncs nrd d[7:0] a1 page address a3 a7 d1 d3 d7 ncsrdpulse nrdpulse nrdpulse
519 32054f?avr32?09/09 at32ap7002 27.7 user interface the smc is programmed using the registers listed in table 27-7 on page 519 . for each chip select, a set of four registers is used to program the parameters of the external device connected on it. in table 27-7 on page 519 , ?cs_number? denotes the chip select number. sixteen bytes (0x10) are required per chip select. the user must complete writing the configuration by writing anyone of the mode registers. table 27-7. smc register memory map offset register register name access reset 0x00 + cs_number*0x10 setup re gister setup read/write 0x01010101 0x04 + cs_number*0x10 pulse register pulse read/write 0x01010101 0x08 + cs_number*0x10 cycle register cycle read/write 0x00030003 0x0c + cs_number*0x10 mode register mode read/write 0x10002103
520 32054f?avr32?09/09 at32ap7002 27.7.1 setup register register name: setup access type: read/write offset: 0x00 + cs_number*0x10 reset value: 0x01010101 ? ncsrdsetup: ncs setup length in read access in read access, the ncs signal setup length is defined as: ? nrdsetup: nrd setup length the nrd signal setup length is defined in clock cycles as: ? ncswrsetup: ncs setup length in write access in write access, the ncs signal setup length is defined as: ? nwesetup: nwe setup length the nwe signal setup length is defined as: 31 30 29 28 27 26 25 24 ?? ncsrdsetup 23 22 21 20 19 18 17 16 ?? nrdsetup 15 14 13 12 11 10 9 8 ?? ncswrsetup 76543210 ?? nwesetup ncs setup length in read access 128 ncsrdsetup 5 [] ncsrdsetup 4:0 [] + () clock cycles = nrd setup length 128 nrdsetup 5 [] nrdsetup 4:0 [] + () clock cycles = ncs setup length in write access 128 ncswrsetup 5 [] ncswrsetup 4:0 [] + () clock cycles = nwe setup length 128 nwesetup 5 [] nwesetup 4:0 [] + () clock cycles =
521 32054f?avr32?09/09 at32ap7002 27.7.2 pulse register register name: pulse access type: read/write offset: 0x04 + cs_number*0x10 reset value: 0x01010101 ? ncsrdpulse: ncs pulse length in read access in standard read access, the ncs signal pulse length is defined as: the ncs pulse lengt h must be at least one clock cycle. in page mode read access, the ncsrdpulse field defines the duration of the first access to one page. ? nrdpulse: nrd pulse length in standard read access, the nrd signal puls e length is defined in clock cycles as: the nrd pulse length must be at least one clock cycle. in page mode read access, the nrdpulse field defines t he duration of the subsequent accesses in the page. ? ncswrpulse: ncs pulse length in write access in write access, the ncs signal pulse length is defined as: the ncs pulse lengt h must be at least one clock cycle. ? nwepulse: nw e pulse length the nwe signal pulse length is defined as: the nwe pulse leng th must be at least one clock cycle. 31 30 29 28 27 26 25 24 ? ncsrdpulse 23 22 21 20 19 18 17 16 ? nrdpulse 15 14 13 12 11 10 9 8 ? ncswrpulse 76543210 ? nwepulse ncs pulse length in read access 256 ncsrdpulse 6 [] ncsrdpulse 5:0 [] + () clock cycles = nrd pulse length 256 nrdpulse 6 [] nrdpulse 5:0 [] + () clock cycles = ncs pulse length in write access 256 ncswrpulse 6 [] ncswrpulse 5:0 [] + () clock cycles = nwe pulse length 256 nwepulse 6 [] nwepulse 5:0 [] + () clock cycles =
522 32054f?avr32?09/09 at32ap7002 27.7.3 cycle register register name: cycle access type: read/write offset: 0x08 + cs_number*0x10 reset value: 0x00030003 ? nrdcycle[8:0]: total read cycle length the total read cycle leng th is the total duration in clock cycles of the read cycle. it is equal to the sum of the setup, pulse and hold steps of the nrd and ncs signals. it is defined as: ? nwecycle[8:0]: total write cycle length the total write cycle length is the total duration in clock cycles of the write cycle. it is equal to the sum of the setup, pul se and hold steps of the nwe and ncs signals. it is defined as: 31 30 29 28 27 26 25 24 ??????? nrdcycle[8] 23 22 21 20 19 18 17 16 nrdcycle[7:0] 15 14 13 12 11 10 9 8 ??????? nwecycle[8] 76543210 nwecycle[7:0] read cycle length 256 nrdcycle 8:7 [] nrdcycle 6:0 [] + () clock cycles = write cycle length 256 nwecycle 8:7 [] nwecycle 6:0 [] + () clock cycles =
523 32054f?avr32?09/09 at32ap7002 27.7.4 mode register register name: mode access type: read/write offset: 0x0c + cs_number*0x10 reset value: 0x10002103 ? ps: page size if page mode is enabled, this field indicates the size of the page in bytes. ? pmen: page mode enabled 1: asynchronous burst read in page mode is applied on the corresponding chip select. 0: standard read is applied. ? tdfmode: tdf optimization 1: tdf optimization is enabled. the number of tdf wait states is optimized using the setup period of the next read/write access. 0: tdf optimization is disabled.the number of tdf wait states is inserted before the next access begins. ? tdfcycles: data float time this field gives the integer numb er of clock cycles required by the external de vice to release the dat a after the rising edge o f the read controlling signal. the smc always provide one full cycle of bus turnaround after the tdfcycles period. the external bus cannot be used by another chip select during tdfcycle s plus one cycles. from 0 up to 15 tdfcycles can be set. 31 30 29 28 27 26 25 24 ?? ps ??? pmen 23 22 21 20 19 18 17 16 ??? tdfmode tdfcycles 15 14 13 12 11 10 9 8 ?? dbw ??? bat 76543210 ?? exnwmode ??writemode readmode ps page size 0 4-byte page 1 8-byte page 2 16-byte page 3 32-byte page
524 32054f?avr32?09/09 at32ap7002 ? dbw: data bus width ? bat: byte access type this field is used only if dbw defines a 16- or 32-bit data bus. ? exnwmode: external wait mode the nwait signal is used to extend the current read or write signal. it is only taken into account during the pulse phase of th e read and write contro lling signal. when the use of nwai t is enabled, at least one cycle ho ld duration must be programmed for the read and write controlling signal. ? writemode: write mode 1: the write operation is controlled by the nwe signal. if td f optimization is enabled (tdfmode =1), tdf wait states will be inserted after the setup of nwe. 0: the write operation is controlled by the ncs signal. if tdf opt imization is enabled (tdfmode =1), tdf wait states will be inserted after the setup of ncs. dbw data bus width 08-bit bus 116-bit bus 232-bit bus 3 reserved bat byte access type 0 byte select access type: write operation is controlled using ncs, nwe, nbs0, nbs1, nbs2, and nbs3 read operation is controlled using ncs, nrd, nbs0, nbs1, nbs2, and nbs3 1 byte write access type: write operation is controlled using ncs, nwr0, nwr1, nwr2, and nwr3 read operation is controlled using ncs and nrd exnwmode external nwait mode 0 disabled: the nwait input signal is ignored on the corresponding chip select. 1 reserved 2 frozen mode: if asserted, the nwait signal freezes the current read or write cycle. after deassertion, the read or write cycle is resumed from the poi nt where it was stopped. 3 ready mode: the nwait signal indicates the availability of the external device at the end of the pu lse of the controlling read or write signal, to complete the access. if high, the ac cess normally completes. if low, the access is extended until nwait returns high.
525 32054f?avr32?09/09 at32ap7002 ? readmode: read mode readmode read access mode 0 the read operation is controlled by the ncs signal. if tdf are programmed, the external bus is marked busy after the rising edge of ncs. if tdf optimization is enabled (tdfmode = 1), tdf wa it states are inserted after the setup of ncs. 1 the read operation is controlled by the nrd signal. if tdf cycles are programmed, the external bus is marked busy after the rising edge of nrd. if tdf optimization is enabled (tdf mode =1), tdf wait states are inserted after the setup of nrd.
526 32054f?avr32?09/09 at32ap7002 28. sdram controller (sdramc) rev: 2.0.0.3 28.1 features ? 256-mbytes address space ? numerous configurations supported ? 2k, 4k, 8k row address memory parts ? sdram with two or four internal banks ? sdram with 16- or 32-bit data path ? programming facilities ? word, halfword, byte access ? automatic page break when memory boundary has been reached ? multibank ping-pong access ? timing parameters specified by software ? automatic refresh operation, refresh rate is programmable ? automatic update of ds, tcr and pa sr parameters (mobile sdram devices) ? energy-saving capabilities ? self-refresh, power-down, and deep power-down modes supported ? supports mobile sdram devices ? error detection ? refresh error interrupt ? sdram power-up initialization by software ? cas latency of one, two, and three supported ? auto precharge command not used 28.2 overview the sdram controller (sdramc) extends the memory capabilities of a chip by providing the interface to an external 16-bit or 32-bit sdram device. the page size supports ranges from 2048 to 8192 and the number of columns from 256 to 2048. it supports byte (8-bit), halfword (16- bit) and word (32-bit) accesses. the sdramc supports a read or write burst length of one location. it keeps track of the active row in each bank, thus maximizing sdram perfo rmance, e.g., the application may be placed in one bank and data in the other banks. so as to optimize performance, it is advisable to avoid accessing different rows in the same bank. the sdramc supports a cas latency of one, two, or three and optimizes the read access depending on the frequency. the different modes available (self refresh, power-down, and deep power-down modes) mini- mize power consumption on the sdram device.
527 32054f?avr32?09/09 at32ap7002 28.3 block diagram figure 28-1. sdram controller block diagram 28.4 i/o lines description memory controller power manager clk_sdramc sdramc chip select sdramc interrupt sdramc user interface peripheral bus i/o controller sdcs sdck sdcke ba[1:0] ras cas sdwe dqm[0] sdramc_a[9:0] d[31:0] ebi mux logic data[31:0] sdck sdcke sdcs ras cas addr[17:16] sdwe addr[0] dqm[1] nwe1 dqm[2] addr[1] dqm[3] nwe3 addr[11:2] sdramc_a[10] sda10 sdramc_a[12:11] addr[13:14] table 28-1. i/o lines description name description type active level sdck sdram clock output sdcke sdram clock enable output high sdcs sdram chip select output low ba[1:0] bank sele ct signals output ras row signal output low cas column signal output low sdwe sdram write enable output low dqm[3:0] data mask enable signals output high sdramc_a[12:0] address bus output d[31:0] data bus input/output
528 32054f?avr32?09/09 at32ap7002 28.5 application example 28.5.1 hardware interface figure 28-2 on page 528 shows an example of sdram device connection to the sdramc using a 32-bit data bus width. figure 28-3 on page 529 shows an example of sdram device connection using a 16-bit data bus width. it is important to note that these examples are given for a direct connection of the devices to the sd ramc, without external bus interface or i/o con- troller multiplexing. figure 28-2. sdram controller connections to sdra m devices: 32-bit data bus width sdramc_a[0-9], sdramc_a11 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 sdramc_a[0-9], sdramc_a11 sdramc_a[0-9], sdramc_a11 sdramc_a[0-9], sdramc_a11 d8-d15 dqm1 dqm0 d0-d7 dqm2 d16-d23 dqm3 d24-d31 sdram controller sdcs ba1 ba0 sdramc_a[0-12] dqm[0-3] sdwe sdcke sdck cas ras d0-d31
529 32054f?avr32?09/09 at32ap7002 figure 28-3. sdram controller connections to sdra m devices: 16-bit data bus width 28.5.2 software interface the sdram address space is organized into banks, rows, and columns. the sdramc allows mapping different memory types according to the values set in the sdramc configuration reg- ister (cr). the sdramc?s function is to ma ke the sdram device access protocol transparent to the user. table 28-2 on page 530 to table 28-7 on page 531 illustrate the sdram device memory map- ping seen by the user in correlation with the device structure. various configurations are illustrated. 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 2mx8 sdram d0-d7 cs dqm clk cke we ras cas a0-a9 a11 ba0 a10 ba1 sdramc_a10 ba0 ba1 sdcs ba1 ba0 sdramc_a[0-12] sdram controller dqm[0-1] sdwe sdcke sdck cas ras d0-d31 dqm0 d0-d7 d8-d15 dqm1
530 32054f?avr32?09/09 at32ap7002 28.5.2.1 32-bit memory data bus width notes: 1. m[1:0] is the byte address inside a 32-bit word. table 28-2. sdram configuration mapping: 2k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 ba[1:0] row[10:0] column[7:0] m[1:0] ba[1:0] row[10:0] column[8:0] m[1:0] ba[1:0] row[10:0] column[9:0] m[1:0] ba[1:0] row[10:0] column[10:0] m[1:0] table 28-3. sdram configuration mapping: 4k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 ba[1:0] row[11:0] column[7:0] m[1:0] ba[1:0] row[11:0] column[8:0] m[1:0] ba[1:0] row[11:0] column[9:0] m[1:0] ba[1:0] row[11:0] column[10:0] m[1:0] table 28-4. sdram configuration mapping: 8k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 ba[1:0] row[12:0] column[7:0] m[1:0] ba[1:0] row[12:0] column[8:0] m[1:0] ba[1:0] row[12:0] column[9:0] m[1:0] ba[1:0] row[12:0] column[10:0] m[1:0]
531 32054f?avr32?09/09 at32ap7002 28.5.2.2 16-bit memory data bus width notes: 1. m0 is the byte address inside a 16-bit halfword. 28.6 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 28.6.1 i/o lines the sdramc module signals pass through the external bus interface (ebi) module where they are multiplexed. the user must first configure the i/o controller to assign the ebi pins corre- sponding to sdramc signals to their peripheral function. if i/o lines of the ebi corresponding to sdramc signals are not used by the application, they can be used for other purposes by the i/o controller. table 28-5. sdram configuration mapping: 2k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0987654321 0 ba[1:0] row[10:0] column[7:0] m0 ba[1:0] row[10:0] column[8:0] m0 ba[1:0] row[10:0] column[9:0] m0 ba[1:0] row[10:0] column[10:0] m0 table 28-6. sdram configuration mapping: 4k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0987654321 0 ba[1:0] row[11:0] column[7:0] m0 ba[1:0] row[11:0] column[8:0] m0 ba[1:0] row[11:0] column[9:0] m0 ba[1:0] row[11:0] column[10:0] m0 table 28-7. sdram configuration mapping: 8k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0987654321 0 ba[1:0] row[12:0] column[7:0] m0 ba[1:0] row[12:0] column[8:0] m0 ba[1:0] row[12:0] column[9:0] m0 ba[1:0] row[12:0] column[10:0] m0
532 32054f?avr32?09/09 at32ap7002 28.6.2 power management the sdramc must be properly stopped before entering in reset mode, i.e., the user must issue a deep power mode command in the mode (md) register and wait for the command to be completed. 28.6.3 clocks the clock for the sdramc bus interface (clk _sdramc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the sdramc before disabling the clock, to avoid freezing the sdramc in an undefined state. 28.6.4 interrupts the sdramc interrupt request line is connected to the interrupt controller. using the sdramc interrupt requires the interrupt controller to be programmed first. 28.7 functional description 28.7.1 sdram device initialization the initialization sequence is generated by softw are. the sdram devices are initialized by the following sequence: 1. sdram features must be defined in the cr register by writing the following fields with the desired value: asynchronous timings (txsr, tras, trcd, trp, trc, and twr), number of columns (nc), numb er of rows (nr), number of banks (nb), cas latency (cas), and the data bus width (dbw). 2. for mobile sdram devices, temperature compensated self refresh (tcsr), drive strength (ds) and partial array self refresh (pasr) fields must be defined in the low power register (lpr). 3. the memory device type field must be defined in the memory device register (mdr.md). 4. a no operation (nop) command must be i ssued to the sdram devices to start the sdram clock. the user must write the value one to the command mode field in the sdramc mode register (mr.mode) and perform a write access to any sdram address. 5. a minimum pause of 200s is provided to precede any signal toggle. 6. an all banks precharge command must be issued to the sdram devices. the user must write the value two to the mr.mode field and perform a write access to any sdram address. 7. eight auto refresh commands are provided. the user must write the value four to the mr.mode field and performs a write access to any sdram location eight times. 8. a load mode register command must be issued to program the parameters of the sdram devices in its mode register, in particular cas latency, burst type, and burst length. the user must write the value three to the mr.mode field and perform a write access to the sdram. the write address must be chosen so that ba[1:0] are set to zero. see section 28.8.1 for details about load mode register command. 9. for mobile sdram initialization, an extended load mode register command must be issued to program the sdram devices parameters (tcsr, pasr, ds). the user must write the value five to the mr.mode field and perform a write access to the sdram. the
533 32054f?avr32?09/09 at32ap7002 write address must be chosen so that ba[1] or ba[0] are equal to one. see section 28.8.1 for details about extended load mode register command. 10. the user must go into normal mode, writing the value 0 to the mr.mode field and per- forming a write access at any location in the sdram. 11. write the refresh rate into the refresh timer count field in the refresh timer register (tr.count). the refresh rate is the delay between two successive refresh cycles. the sdram device requires a refresh every 15.625s or 7.81s. with a 100mhz frequency, the tr register must be written with the value 1562 (15.625 s x 100 mhz) or 781 (7.81 s x 100 mhz). after initialization, the sdram devices are fully functional. figure 28-4. sdram device initialization sequence 28.7.2 sdram controller write cycle the sdramc allows burst access or single acce ss. in both cases, the sdramc keeps track of the active row in each bank, thus maximizing performance. to initiate a burst access, the sdramc uses the transfer type signal provided by the master requesting the access. if the next access is a sequential write a ccess, writing to the sdram devi ce is carried out. if the next access is a write-sequential access, but the current access is to a boundary page, or if the next access is in another row, then the sdramc generates a precharge command, activates the new row and initiates a write co mmand. to comply with sdram timing parameters, additional clock cycles are inserted between precharge and active (t rp ) commands and between active and write (t rcd ) commands. for definition of these timing parameters, refer to the section 28.8.3 . this is described in figure 28-5 on page 534 . sdcke sdck sdramc_a[9:0] a10 sdramc_a[12:11] sdcs ras cas sdwe dqm inputs stable for 200 usec valid command precharge all banks 1st auto refresh 8th auto refresh lmr command t mrd t rc t rp
534 32054f?avr32?09/09 at32ap7002 figure 28-5. write burst, 16-bit sdram access 28.7.3 sdram controller read cycle the sdramc allows burst access, incremental bur st of unspecified length or single access. in all cases, the sdramc keeps track of the acti ve row in each bank, thus maximizing perfor- mance of the sdram. if row and bank addresse s do not match the previous row/bank address, then the sdramc automatically generates a precharge command, activates the new row and starts the read command. to comply with the sdram timing para meters, additional clock cycles on sdck are inserted between precharge and active (t rp ) commands and between active and read (t rcd ) commands. these two parameters are set in the cr register of the sdramc. after a read command, additional wait states are generated to comply with the cas latency (one, two, or three clock delays specified in the cr register). for a single access or an incremented burst of unspecified length, the sdramc anticipates the next access. while the last valu e of the column is returned by the sdramc on the bus, the sdramc anticipates the read to the next column and thus anticipates the cas latency. this reduces the effect of the cas latency on the internal bus. for burst access of specified length (4, 8, 16 words), access is not anticipated. this case leads to the best performance. if the burst is broken (border, busy mode, etc.), the next access is han- dled as an incrementing burst of unspecified length. sdcs t rcd = 3 sdck sdramc_a[12:0] ras cas sdwe d[15:0] dna dnb dnc dnd dne dnf dng dnh dni dnj dnk dnl row n col b col c col d col e col f col g col h col i col k col l col j col a
535 32054f?avr32?09/09 at32ap7002 figure 28-6. read burst, 16-bit sdram access 28.7.4 border management when the memory row boundary has been reached, an automatic page break is inserted. in this case, the sdramc generates a precharge command, activates the new row and initiates a read or write command. to comply with sdram timing parameters, an additional clock cycle is inserted between the precharge and active (t rp ) commands and between the active and read (t rcd ) commands. this is described in figure 28-7 on page 536 . sdcs d[15:0] (input) sdck sdramc_a[12:0] ras cas sdwe dna dnb dnc dnd dne dnf col a col b col c col d col e col f row n cas = 2 t rcd = 3
536 32054f?avr32?09/09 at32ap7002 figure 28-7. read burst with boundary row access 28.7.5 sdram controller refresh cycles an auto refresh command is used to refresh the sdram device. refresh addresses are gener- ated internally by the sdram device and incr emented after each auto refresh automatically. the sdramc generates these auto refresh commands periodically. an internal timer is loaded with the value in the refresh timer register (tr) that indicates the number of clock cycles between successive refresh cycles. a refresh error interrupt is generated when the previous auto refresh command did not perform. in this case a refresh error status bit is set in the interrupt status register (isr.res). it is cleared by reading the isr register. when the sdramc initiates a refresh of the sdram device, internal memory accesses are not delayed. however, if the cpu tr ies to access the sdram, the slave indicates that the device is busy and the master is held by a wait signal. see figure 28-8 on page 537 . sdcs sdck sdramc_a[12:0] cas ras sdwe d[15:0] dna dnb dnc dnd dma dmb dmc dme dmd row m col a col b col c col d col e row n col a col b col c col d cas = 2 t rcd = 3 t rp = 3
537 32054f?avr32?09/09 at32ap7002 figure 28-8. refresh cycle followed by a read access 28.7.6 power management three low power modes are available: ? self refresh mode: the sdram executes its own auto refresh cycles without control of the sdramc. current drained by the sdram is very low. ? power-down mode: auto refresh cycles are controlled by the sdramc. between auto refresh cycles, the sdram is in power-down. current drained in power-down mode is higher than in self refresh mode. ? deep power-down mode (only available with mobile sdram): the sdram contents are lost, but the sdram does not drain any current. the sdramc activates one low power mode as so on as the sdram device is not selected. it is possible to delay the entry in self refresh and power-down mode after the last access by config- uring the timeout field in the low power register (lpr.timeout). 28.7.6.1 self refresh mode this mode is selected by writing the value one to the low power configuration bits field in the sdramc low power register (l pr.lpcb). in self refresh mode, the sdram device retains data without external clocking and provides its own internal clocking, thus performing its own auto refresh cycles. all the inputs to the sdra m device become ?don?t care? except sdcke, which remains low. as soon as the sdram dev ice is selected, the sdramc provides a sequence of commands and exits self refresh mode. some low power sdrams (e.g., mobile sdram) can refresh only one quarter or a half quarter or all banks of the sdram array. this feature reduces the self refresh current. to configure this feature, temperature compensated self refresh (tcsr), partial array self refresh (pasr) sdcs sdck sdramc_a[12:0] row n col c col d ras cas sdwe d[15:0] (input) dnb dnc dnd dma col a row m cas = 2 t rcd = 3 t rc = 8 t rp = 3
538 32054f?avr32?09/09 at32ap7002 and drive strength (ds) parameters must be set by writing the corresponding fields in the lpr register, and transmitted to the low po wer sdram device during initialization. after initialization, as soon as the lpr.pasr, lpr.ds, or lpr.tcsr fields are modified and self refresh mode is activated, the sdramc issues an extended load mode register command to the sdram and the extended mode register of the sdram device is accessed automati- cally. the pasr/ds/tcsr parameters values are therefore updated before entry into self refresh mode. the sdram device must remain in self refresh mode for a minimum period of t ras and may remain in self refresh mode for an indefinite period. this is described in figure 28-9 on page 538 . figure 28-9. self refresh mode behavior 28.7.6.2 low power mode this mode is selected by writing the value two to the lpr.lpcb field. power consumption is greater than in self refresh mode. all the i nput and output buffers of the sdram device are deactivated except sdcke, whic h remains low. in contrast to self refresh mode, the sdram device cannot remain in low power mode longer than the refresh period (64ms for a whole device refresh operation). as no auto refresh operations are performed by the sdram itself, the sdramc carries out the refresh operation. the exit procedure is faster than in self refresh mode. this is described in figure 28-10 on page 539 . sdramc_a[12:0] sdck sdcke sdcs ras cas access request to the sdram controller self refresh mode row t xsr = 3 sdwe
539 32054f?avr32?09/09 at32ap7002 figure 28-10. low power mode behavior 28.7.6.3 deep power-down mode this mode is selected by writing the value three to the lpr.lpcb field. when this mode is acti- vated, all internal voltage generators inside the sdram are stopped and all data is lost. when this mode is enabled, the user must no t access to the sdram until a new initialization sequence is done (see section 28.7.1 ). this is described in figure 28-11 on page 540 . low power mode cas = 2 t rcd = 3 sdcs sdck sdramc_a[12:0] ras cas sdcke d[15:0] (input) dna dnb dnc dnd dne dnf col f col e col d col c col b col a row n
540 32054f?avr32?09/09 at32ap7002 figure 28-11. deep power-down mode behavior sdcs sdck sdramc_a[12:0] ras cas sdwe scke d[15:0] (input) dnb dnc dnd col d col c row n t rp = 3
541 32054f?avr32?09/09 at32ap7002 28.8 user interface table 28-8. sdramc register memory map offset register register name access reset 0x00 mode register mr read/write 0x00000000 0x04 refresh timer register tr read/write 0x00000000 0x08 configuration register cr read/write 0x852372c0 0x0c high speed register hsr read/write 0x00000000 0x10 low power register lpr read/write 0x00000000 0x14 interrupt enable register ier write-only 0x00000000 0x18 interrupt disable register idr write-only 0x00000000 0x1c interrupt mask register imr read-only 0x00000000 0x20 interrupt status register isr read-only 0x00000000 0x24 memory device register mdr read/write 0x00000000
542 32054f?avr32?09/09 at32ap7002 28.8.1 mode register register name :mr access type : read/write offset: 0x00 reset value : 0x00000000 ? mode: command mode this field defines the command issued by t he sdramc when the sdram device is accessed. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----- mode mode description 0 normal mode. any access to the sdram is decoded normally. 1 the sdramc issues a ?nop? command when the sdram device is accessed regardless of the cycle. 2 the sdramc issues an ?all banks precharge? command when the sdram device is accessed regardless of the cycle. 3 the sdramc issues a ?load mode register? command wh en the sdram device is accessed regardless of the cycle. this command will load the cr.c as field into the sdram device mode register. all the other parameters of the sdram device mode register will be set to zero (burst length, burst type, operating mode, write burst mode...). 4 the sdramc issues an ?auto refres h? command when the sdram device is accessed regardless of the cycle. previously, an ?all banks precharge? command must be issued. 5 the sdramc issues an ?extended load mode register? command when the sdram device is accessed regardless of the cycle. this command will load the lpr.pasr, lpr.ds, and lpr.tcr fields into the sdram device extended mode register. all the other bits of th e sdram device extended mode register will be set to zero. 6 deep power-down mode. enters deep power-down mode.
543 32054f?avr32?09/09 at32ap7002 28.8.2 refresh timer register register name :tr access type : read/write offset: 0x04 reset value : 0x00000000 ? count[11:0]: refresh timer count this 12-bit field is loaded into a timer that generates the refres h pulse. each time the refresh pulse is generated, a refresh burst is initiated. the value to be loaded depends on the sdramc clock frequency (clk_sdramc), the refresh rate of the sdram device and the refresh burst length where 15.6s per row is a typical value for a burst of length one. to refresh the sdram device, this 12-bit fiel d must be written. if this condition is not satisfied, no refresh command is issue d and no refresh of the sdram device is carried out. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - count[11:8] 76543210 count[7:0]
544 32054f?avr32?09/09 at32ap7002 28.8.3 configuration register register name :cr access type : read/write offset: 0x08 reset value : 0x852372c0 ? txsr: exit self refr esh to active delay reset value is eight cycles. this field defines the delay between scke set high and an activate command in number of cycles. number of cycles is between 0 and 15. ? tras: active to precharge delay reset value is five cycles. this field defi nes the delay between an activate co mmand and a precharge command in numb er of cycles. number of cycles is between 0 and 15. ? trcd: row to column delay reset value is two cycles. this field defines the delay between an activate command and a r ead/write command in number of cycles. number of cycles is between 0 and 15. ? trp: row precharge delay reset value is three cycles. this field defines the delay between a pr echarge command and another command in number of cycles. number of cycles is between 0 and 15. ? trc: row cycle delay reset value is seven cycles. this field defines the delay between a refresh and an activate co mmand in number of cycles. number of cycles is between 0 and 15. ? twr: write recovery delay reset value is two cycles. this field defines the write recovery time in number of cycles. number of cycles is between 0 and 15. ? dbw: data bus width reset value is 16 bits. 0: data bus width is 32 bits. 1: data bus width is 16 bits. 31 30 29 28 27 26 25 24 txsr tras 23 22 21 20 19 18 17 16 trcd trp 15 14 13 12 11 10 9 8 trc twr 76543210 dbw cas nb nr nc
545 32054f?avr32?09/09 at32ap7002 ? cas: cas latency reset value is two cycles. in the sdramc, only a cas latency of one, two and three cycles is managed. ? nb: number of banks reset value is two banks. ? nr: number of row bits reset value is 11 row bits. ? nc: number of column bits reset value is 8 column bits. cas cas latency (cycles) 0reserved 11 22 33 nb number of banks 02 14 nr row bits 011 112 213 3reserved nc column bits 08 19 210 311
546 32054f?avr32?09/09 at32ap7002 28.8.4 high speed register register name :hsr access type : read/write offset: 0x0c reset value: 0x00000000 ? da: decode cycle enable a decode cycle can be added on the addre sses as soon as a non-sequential access is performed on the hsb bus. the addition of the dec ode cycle allows the sdra mc to gain time to a ccess the sdram memory. 1: decode cycle is enabled. 0: decode cycle is disabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------da
547 32054f?avr32?09/09 at32ap7002 28.8.5 low power register register name :lpr access type : read/write offset: 0x10 reset value : 0x00000000 ? timeout: time to define when low power mode is enabled ? ds: drive strength (only for low power sdram) this field is transmitted to the sdram during initialization to se lect the sdram strength of data output. this parameter must b e set according to the sdram device specification. after initialization, as soon as this field is modified and self refresh mode is activated, t he extended mode register of the sdram device is accessed automatically and its ds parameter value is updated before entry in self refresh mode. ? tcsr: temperature compensated self refresh (only for low power sdram) this field is transmitted to the sdram during initialization to set the refresh interval during self refresh mode depending on the temperature of the low power sdram. this parameter must be set according to the sdram device specification. after initialization, as soon as this field is modified and self refresh mode is activated, t he extended mode register of the sdram device is accessed autom atically and its tcsr parameter value is u pdated before entry in self refresh mode. ? pasr: partial array self refresh (only for low power sdram) this field is transmitted to the sdram during initialization to sp ecify whether only one quarter, one half or all banks of the sdram array are enabled. disabled banks are not refreshed in self refresh mode. this parameter must be set according to the sdram device specification. after initialization, as soon as this field is modified and self refresh mode is activated, t he extended mode register of the sdram device is accessed autom atically and its pasr parameter value is u pdated before entry in self refresh mode. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -- timeout ds tcsr 76543210 - pasr - - lpcb timeout time to define when low power mode is enabled 0 the sdramc activates the sdram low power mode i mmediately after the end of the last transfer. 1 the sdramc activates the sdram low power mode 64 clock cycles after the end of the last transfer. 2 the sdramc activates the sdram low power mode 128 clock cycles after the end of the last transfer. 3 reserved.
548 32054f?avr32?09/09 at32ap7002 ? lpcb: low power configuration bits lpcb low power configuration 0 low power feature is inhibited: no power-down, self refresh or deep power-down command is issued to the sdram device. 1 the sdramc issues a self refresh command to the sdram device, the sdclk clock is deactivated and the sdcke signal is set low. the sdram device leaves the self refresh mode when accessed and enters it after the access. 2 the sdramc issues a power-down command to the sdram device after each access, the sdcke signal is set to low. the sdram device leaves the power-down mode when accessed and enters it after the access. 3 the sdramc issues a deep power-down command to the sdram device. this mode is unique to low- power sdram.
549 32054f?avr32?09/09 at32ap7002 28.8.6 interrupt enable register register name :ier access type : write-only offset: 0x14 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
550 32054f?avr32?09/09 at32ap7002 28.8.7 interrupt disable register register name :idr access type : write-only offset: 0x18 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
551 32054f?avr32?09/09 at32ap7002 28.8.8 interrupt mask register register name :imr access type : read-only offset: 0x1c reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
552 32054f?avr32?09/09 at32ap7002 28.8.9 interrupt status register register name :isr access type : read-only offset: 0x20 reset value: 0x00000000 ? res: refresh error status this bit is set when a refresh error is detected. this bit is cleared when the register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------res
553 32054f?avr32?09/09 at32ap7002 28.8.10 memory device register register name :mdr access type : read/write offset: 0x24 reset value: 0x00000000 ? md: memory device type 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ------ md md device type 0 sdram 1 low power sdram other reserved
554 32054f?avr32?09/09 at32ap7002 29. error corrected code (ecc) controller rev: 1.0.0.0 29.1 features ? hardware error corrected code (ecc) generation ? detection and correction by software ? supports nand flash and smartmedia ? devices with 8- or 16-bit data path. ? supports nand flash/smartmedia with page size s of 528, 1056, 2112 and 4224 bytes, specified by software 29.2 description nand flash/smartmedia devices contain by default invalid blocks which have one or more invalid bits. over the nand flash/smartmedia lifetime, additional invalid blocks may occur which can be detected/corrected by ecc code. the ecc controller is a mechanism that encodes data in a manner that makes possible the identification and correction of certain errors in data. the ecc controller is capable of single bit error correction and 2-bit random detection. w hen nand flash/smartmedia have more than 2 bits of errors, the data cannot be corrected. the ecc user interface is accesi ble through the peripheral bus. 29.3 block diagram figure 29-1. block diagram user interface ctrl/ecc algorithm static memory controller peripheral bus nand flash smartmedia logic ecc controller
555 32054f?avr32?09/09 at32ap7002 29.4 functional description a page in nand flash and smartmedia memories contains an area for main data and an addi- tional area used for redundancy (ecc). the page is organized in 8-bit or 16-bit words. the page size corresponds to the number of words in the main data plus the number of words in the extra area used for redundancy. the only configuration requir ed for ecc is the nand flash or the smartmedia page size (528/1056/2112/4224). page size is configured setting the pagesize field in the ecc mode register (mr). ecc is automatically computed as soon as a read (00h)/write (80h) command to the nand flash or the smartmedia is detected. read and write access must start at a page boundary. ecc is computed as soon as the counter reaches the page size. values in the ecc parity reg- ister (pr) and ecc nparity register (npr) are then valid and locked until a new start condition (read/write command followed by five access address cycles). 29.4.1 write access once the flash memory page is written, the computed ecc code is available in the ecc parity error (pr) and ecc_nparity error (npr) registers. the ecc code value must be written by the software application at the end of the page, in the extra area used for redundancy. 29.4.2 read access after reading main data in the page area, the application can perform read access to the extra area used for redundancy. error detection is automatically performed by the ecc controller. the application can check the ecc status register (sr) for any detected errors. it is up to the application to correct any detected error. ecc computation can detect four differ- ent circumstances: ?no error: xor between the ecc computation and the ecc code stored at the end of the nand flash or smartmedia page is equal to 0. no error flags in the ecc status register (sr). ?recoverable error: only the recerr flag in the ecc status register (sr) is set. the corrupted word offset in the read page is defined by the wordaddr field in the ecc parity register (pr). the corrupted bit position in the concerned word is defined in the bitaddr field in the ecc parity register (pr). ?ecc error: the eccerr flag in the ecc status register is set. an error has been detected in the ecc code stored in the flash memory. the position of the corrupted bit can be found by the application performing an xor between the parity and the nparity contained in the ecc code stored in the flash memory. ?non correctable error: the mulerr flag in the ecc status register is set. several unrecoverable errors have been detected in the flash memory page. ecc status register, ecc parity register and ecc nparity register are cleared when a read/write command is detected or a software register is enabled. for single bit error correction and double bit erro r detection (sec-ded) hsiao code is used. 32- bit ecc is generated in order to perform one bit correction per 512/1024/2048/4096 8- or 16-bit
556 32054f?avr32?09/09 at32ap7002 words. of the 32 ecc bits, 26 bits are for line parity and 6 bits are for column parity. they are generated according to the schemes shown in figure 29-2 and figure 29-3 . figure 29-2. parity generation for 512/1024/2048/4096 8-bit words1 to calculate p8? to px? and p8 to px, apply the algorithm that follows. page size = 2 n for i =0 to n begin for (j = 0 to page_size_byte) begin if(j[i] ==1) p[2 i+3 ]=bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ] else p[2 i+3 ]?=bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ]' end end bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' p16 p16' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' p16 p16' p32 p32 1st byte p32 2nd byte 3rd byte 4 th byte page size th byte (page size -1 )th byte px px' page size = 512 px = 2048 page size = 1024 px = 4096 page size = 2048 px = 8192 page size = 4096 px = 16384 (page size -2 )th byte (page size -3 )th byte p1 p1' p1' p1 p1 p1' p1' p1 p2 p2' p2 p2' p4 p4' p1=bit7(+)bit5(+)bit3(+)bit1(+)p1 p2=bit7(+)bit6(+)bit3(+)bit2(+)p2 p4=bit7(+)bit6(+)bit5(+)bit4(+)p4 p1'=bit6(+)bit4(+)bit2(+)bit0(+)p1' p2'=bit5(+)bit4(+)bit1(+)bit0(+)p2' p4'=bit7(+)bit6(+)bit5(+)bit4(+)p4'
557 32054f?avr32?09/09 at32ap7002 figure 29-3. parity generation for 512/1024/2048/4096 16-bit words 1st word 2nd word 3rd word 4th word (page size -3 )th word (page size -2 )th word (page size -1 )th word page size th word (+) (+)
558 32054f?avr32?09/09 at32ap7002 to calculate p8? to px? and p8 to px, apply the algorithm that follows. page size = 2 n for i =0 to n begin for (j = 0 to page_size_word) begin if(j[i] ==1) p[2 i+3 ]= bit15(+)bit14(+)bit13(+)bit12(+) bit11(+)bit10(+)bit9(+)bit8(+) bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 n+3 ] else p[2 i+3 ]?=bit15(+)bit14(+)bit13(+)bit12(+) bit11(+)bit10(+)bit9(+)bit8(+) bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ]' end end
559 32054f?avr32?09/09 at32ap7002 29.5 ecc user interface table 29-1. ecc register mapping offset register register name access reset 0x00 ecc control register cr write-only 0x0 0x04 ecc mode register mr read/write 0x0 0x8 ecc status register sr read-only 0x0 0x0c ecc parity register pr read-only 0x0 0x10 ecc nparity register npr read-only 0x0 0x14-0xf8 reserved ? ? ? 0x14 - 0xfc reserved ? ? ?
560 32054f?avr32?09/09 at32ap7002 29.5.1 ecc control register name: cr access type: write-only ? rst: reset parity provides reset to current ecc by software. 0: no effect 1: reset secc parity and ecc nparity register 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????rst
561 32054f?avr32?09/09 at32ap7002 29.5.2 ecc mode register register name :mr access type : read/write ? pagesize: page size this field defines the page size of the nand flash device. a word has a value of 8 bits or 16 bits, depending on the nand flash or smartmedia memory organization. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????? pagesize page size description 00 528 words 01 1056 words 10 2112 words 11 4224 words
562 32054f?avr32?09/09 at32ap7002 29.5.3 ecc status register register name :sr access type : read-only ? recerr: recoverable error 0: no errors detected 1: errors detected. if mulerr is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected ? eccerr: ecc error 0: no errors detected 1: a single bit error occurred in the ecc bytes. read both ecc parity and ecc parityn register, the error occurred at the location which contains a 1 in the least significant 16 bits. ? mulerr: multiple error 0: no multiple errors detected 1: multiple errors detected 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????mulerreccerrrecerr
563 32054f?avr32?09/09 at32ap7002 29.5.4 ecc parity register register name :pr access type : read-only during a page write, the value of the entire register must be written in the extra area used for redundancy (for a 512-byte page size: address 512-513) ? bitaddr during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr during a page read, this value contains the word address (8-bit or 16-bit word depending on the memory plane organiza- tion) where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 wordaddr 76543210 wordaddr bitaddr
564 32054f?avr32?09/09 at32ap7002 29.5.5 ecc nparity register register name :npr access type : read-only ? nparity: during a write, the value of this register must be written in the extra area used for redundancy (for a 512-byte page size: address 514-515) 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 nparity 76543210 nparity
565 32054f?avr32?09/09 at32ap7002 30. multimedia card interface (mci) rev: 2.0.0.3 30.1 features ? compatible with multimedia card specification version 2.2 ? compatible with sd memory card specification version 1.0 ? compatible with multimedia card specification version 3.31 ? compatible with sdio specification version 1.1 ? cards clock rate up to ma ster clock divided by 2 ? embedded power management to slow down clock rate when not used ? supports 2 slots ? each slot for either a multimediacard bus (up to 30 cards) or an sd memory card ? support for stream, block and mu lti-block data read and write ? supports connection to dma controller ? minimizes processor interventi on for large buffer transfers 30.2 overview the mci includes a command register, response registers, data registers, timeout counters and error detection logic that automatically handle the transmission of commands and, when required, the reception of the associated responses and data with a limited processor overhead. the mci supports stream, block and multi-block data read and write, and is compatible with a dma controller, minimizing processor intervention for large buffer transfers. the mci operates at a rate of up to master cloc k divided by 2 and supports the interfacing of 2 slots . each slot may be used to interface with a multimedia card bus (up to 30 cards) or with a sd memory card. only one slot can be selected at a time (slots are multiplexed). a bit field in the sd card register performs this selection. the sd memory card communication is based on a 9-pin interface (clock, command, four data and three power lines) and the multimediacard on a 7-pin interface (clock, command, one data, three power lines and one reserved for future use). the sd memory card interface also supports multimedia card operations. the main differences between sd and multimedia cards are the initialization process and the bus topology.
566 32054f?avr32?09/09 at32ap7002 30.3 block diagram figure 30-1. block diagram clk gpio mci interface interrupt control mci interrupt clk_mci pm peripheral bus pdca peripheral bus bridge data0 data1 data2 data3 data4 data5 data6 data7 cmd0 cmd1
567 32054f?avr32?09/09 at32ap7002 30.4 application block diagram figure 30-2. application block diagram 30.5 i/o lines description note: 1. i: input, o: output, pp: push/pull, od: open drain. 12 3 4 56 mmc 7 1 9 2 345 7 68 sdcard physical layer mci interface application layer ex: file system, audio, security, etc table 30-1. i/o lines description pin name pin description type (1) comments cmd[1:0] command/response i/o/pp/ od cmd of an mmc or sd card clk clock i/o clk of an mmc or sd card data[3..0] data 0..3 of slot a i/o/pp dat0 of an mmc dat[0..3] of an sd card data[7...4] data 0..3 of slot b i/o/pp dat0 of an mmc dat[0..3] of an sd card
568 32054f?avr32?09/09 at32ap7002 30.6 product dependencies 30.6.1 gpio the pins used for interfacing the multimedia ca rds or sd cards may be multiplexed with gpio lines. the programmer must first program the gpio controller to assign the peripheral functions to mci pins. 30.6.2 power manager the mci may receive a clock from the power manager (pm), so the programmer must first con- figure the pm to enable the mci clock(clk_mci). 30.6.3 interrupt controller the mci interface has an interrupt line connected to the interrupt controller (intc). handling the mci interrupt requires programming the intc before configuring the mci. 30.7 functional description 30.7.1 bus topology figure 30-3. multimedia memory card bus topology the multimedia card communication is based on a 7- pin serial bus interface. it has three com- munication lines and four supply lines. note: 1. i: input, o: output, pp : push/pull, od: open drain. table 30-2. bus topology pin number name type (1) description mci pin name (slot x) 1 rsv nc not connected 2 cmd i/o/pp/od command/response cmdx 3 vss1 s supply voltage ground vss 4 vdd s supply voltage vdd 5 clk i/o clock clk 6 vss2 s supply voltage ground vss 7 dat[0] i/o/pp data 0 datax0 12 34567 mmc
569 32054f?avr32?09/09 at32ap7002 figure 30-4. mmc bus connections (one slot) figure 30-5. sd memory card bus topology the sd memory card bus includes the signals listed in table 30-3 on page 569 . note: 1. i: input, o: output, pp: push pull, od: open drain table 30-3. sd memory card bus signals pin number name type (1) description mci pin name (slot x) 1 cd/dat[3] i/o/pp card detect/ data line bit 3 datax3 2 cmd pp command/response cmdx 3 vss1 s supply voltage ground vss 4 vdd s supply voltage vdd 5 clk i/o clock clk 6 vss2 s supply voltage ground vss 7 dat[0] i/o/pp data line bit 0 datax0 8 dat[1] i/o/pp data line bit 1 or interrupt datax1 9 dat[2] i/o/pp data line bit 2 datax2 2 1 345 67 mmc1 2 1 345 67 mmc2 2 1 345 67 mmc3 clk data0 cmd mci 12 4 35678 9 sdcard
570 32054f?avr32?09/09 at32ap7002 figure 30-6. sd card bus connections with two slots figure 30-7. mixing multimedia and sd memory cards with two slots when the mci is configured to operate with sd memory cards, the width of the data bus can be selected in the sdcr regi ster. clearing the sdcbus bit in this register means that the width is one bit; setting it means that the width is four bits. in the case of multimedia cards, only the data line 0 is used. the other data lines can be used as independent gpios. 5 23 6 1478 9 sdcard1 5 23 6 1478 9 sdcard2 data[7..4] cmd0 clk data[3..0] cmd1 12 34567 mmc1 12 34567 mmc2 12 34567 mmc3 4 9 23 156 7 8 sdcard data0 cmd0 clk data[7..4] cmd1
571 32054f?avr32?09/09 at32ap7002 30.7.2 multimedia card operations after a power-on reset, the cards are initialized by a special message-based multimedia card bus protocol. each message is represented by one of the following tokens: ? command: a command is a token that starts an operation. a command is sent from the host either to a single card (addressed command) or to all connected cards (broadcast command). a command is transferred serially on the cmd line. ? response: a response is a token which is sent from an addressed card or (synchronously) from all connected cards to the host as an answer to a previously received command. a response is transferred serially on the cmd line. ? data: data can be transferred from the card to the host or vice versa. data is transferred via the data line. card addressing is implemented using a sess ion address assigned during the initialization phase by the bus controller to all currently connected cards. their unique cid number identifies individual cards. the structure of commands, resp onses and data blocks is descr ibed in the multimedia-card system specification. see also table 30-4 on page 572 . multimediacard bus data transfers are composed of these tokens. there are different types of operations. addressed operations always contain a command and a response token. in addition, some operations have a data token; the others transfer their infor- mation directly within the command or response structure. in this case, no data token is present in an operation. the bits on the dat and the cmd lines are transferred synchronous to the mci clock. two types of data transfer commands are defined: ? sequential commands: these commands initiate a continuous data stream. they are terminated only when a stop command follows on the cmd line. this mode reduces the command overhead to an absolute minimum. ? block-oriented commands: these commands send a data block succeeded by crc bits. both read and write operations allow either single or multiple block transmission. a multiple block transmission is terminated when a stop co mmand follows on the cm d line similarly to the sequential read or when a multiple block transmission has a predefined block count ( see ?data transfer operation? on page 573. ). the mci provides a set of registers to perform the entire range of multimedia card operations. 30.7.2.1 command - response operation after reset, the mci is disabled and becomes va lid after setting the mcien bit in the control register(cr). the two bits rdproof and wrproof in the mode register (mr) allow stopping the mci clock during read or write access if the internal fi fo is full. this will guaran tee data integrity, not bandwidth. the command and the response of the card are clocked out with the rising edge of the mci clock. all the timings for multimedia card are defined in the multim ediacard system specification.
572 32054f?avr32?09/09 at32ap7002 the two bus modes (open drain and push/pull) needed to process all the operations are defined in the mci command register. the cmdr allows a command to be carried out. for example, to perform an all_send_cid command: the command all_send_cid and the fields and values for the cmdr control register are described in table 30-4 and table 30-5 . note: bcr means broadcast command with response. the argr contains the argument field of the command. to send a command, the user must perform the following steps: ? fill the argument register (a rgr) with the command argument. ? set the command register (cmdr) (see table 30-5 ). the command is sent immediately after writing the command register. the status bit cmdrdy in the status register (sr) is asserted when the command is completed. if the command requires a response, it can be read in the response register (rspr). the response size can be from 48 bits up to 136 bits depending on the command. the mci embeds an error detection to prevent any corrupted data during the transfer. the following flowchart shows how to send a command to the card and read the response if needed. in this example, the status register bits are polled but setting the appropriate bits in the interrupt enable register (ier) allows using an interrupt method. host command n id cycles cid cmd s t content crc e z ****** z s t content z z z table 30-4. all_send_cid command description cmd index type argument resp abbreviation command description cmd2 bcr [31:0] stuff bits r2 all_send_cid asks all cards to send their cid numbers on the cmd line table 30-5. fields and values for cmdr command register field value cmdnb (command number) 2 (cmd2) rsptyp (response type) 2 (r2: 136 bits response) spcmd (special command) 0 (not a special command) opcmd (open drain command) 1 maxlat (max latency for command to response) 0 (nid cycles ==> 5 cycles) trcmd (transfer command) 0 (no transfer) trdir (transfer direction) x (available only in transfer command) trtyp (transfer type) x (available only in transfer command)
573 32054f?avr32?09/09 at32ap7002 figure 30-8. command/response functional flow diagram note: 1. if the command is send_op_cond, the crc error flag is always present (refer to r3 response in the multimedi a card specification). 30.7.2.2 data transfer operation the multimedia card allo ws several read/write operations (single block, multiple blocks, stream, etc). these kind of transfers can be selected setting the transfer type (trtyp) field in the i command register (cmdr). these operations can be done using the a dma controller. in all cases, the block length (blklen field) must be defined either in the mr register, or in the block register(blkr). this field determines the size of the data block. enabling pdc force byte transfer (pdcfbyte in the mr) allows the pdc to manage with internal byte transfers, so that transfers of blocks with a size different from modulo 4 can be sup- set the command argument argr = argument (1) set the command cmd = command read sr 0 yes 1 cmdrdy wait for command ready status flag check error bits in the status register (1) status error flags? return ok return error (1) read response if required
574 32054f?avr32?09/09 at32ap7002 ported. when pdc force byte transfer is disabled, the pdc type of transfers are in words, otherwise the type of transfers are in bytes. consequent to mmc specification 3.1, two types of multiple block read (or write) transactions are defined (the host can use either one at any time): ?open-ended/infinite multiple block read (or write): the number of blocks for the read (or write) multiple block operation is not defined. the card will continuously transfer (or program) dat a blocks until a stop transmission command is received. ?multiple block read (or write) with pre-defined block count (since version 3.1 and higher): the card will transfer (or program) the requested number of data blocks and terminate the transaction. the stop command is not required at the end of this type of multiple block read (or write), unless terminated with an error. in or der to start a multiple bl ock read (or write) with pre-defined block count, the host must correctly program the block register (blkr). other- wise the card will start an open-ended multiple block read. the bcnt field of the block register defines the number of blocks to tran sfer (from 1 to 65535 blocks). programming the value 0 in the bcnt field corresponds to an infinite block transfer. 30.7.2.3 read operation the following flowchart shows how to read a single block with or without us e of dma facilities. in this example, a polling method is used to wait for the end of read. similarly, the user can config- ure the ier regsiter to trigger an interrupt at the end of read.
575 32054f?avr32?09/09 at32ap7002 figure 30-9. read functional flow diagram note: 1. this command is supposed to have been correctly sent (see figure 30-8 ). 30.7.2.4 write operation in write operation, the mr register is used to define the padding value when writing non-multiple block size. if the bit dmapadv is 0, then 0x00 value is used when padding data, otherwise 0xff is used. send command sel_desel_card to select the card send command set_blocklen read with dma no yes reset the pdcmode bit mr &= ~pdcmode set the block length (in bytes) mr |= (blocklength << 16) send command read_single_block (1) number of words to read = blocklength/4 set the block length (in bytes) mr |= (blocklength << 16) configure the dma controller send command read_single_block (1) data received? wait for data from mmc number of words to read = 0 ? no yes no yes no no yes yes read status register sr return return return read data = rdr number of words to read = number of words to read - 1 dma transfer complete ? poll the bit rxrdy = 0 ?
576 32054f?avr32?09/09 at32ap7002 the following flowchart shows how to write a singl e block with or without use of dma facilities. polling or interrupt method can be used to wait for the end of write according to the contents of the interrupt mask register (imr).
577 32054f?avr32?09/09 at32ap7002 figure 30-10. write functional flow diagram note: 1. it is assumed that this command has been correctly sent (see figure 30-8 ). send command sel_desel_card to select the card send command set_blocklen no write with dma yes reset the pdcmode bit mr &= ~pdcmode set the block length (in bytes) mr |= (blocklength << 16) send command write_single_block (1) number of words to write = blocklength/4 number of words to write = 0 ? yes no read status register sr yes poll the bit txrdy = 0 ? no tdr = data to write number of words to write = number of words to write - 1 return return dma transfer complete ? yes yes data transmitted? no no wait for data transfert to mmc complete send command write_single_block (1) configure the dma controller set the block length (in bytes) mr |= (blocklength << 16)
578 32054f?avr32?09/09 at32ap7002 30.7.3 sd card operations the multimedia card interface allows processing of sd memory (secure digital memory card) and sdio (sd input output) card commands. sd/sdio cards are based on the multimedia card (mmc) format, but are physically slightly thicker and feature higher data transfer rates, a lock switch on the side to prevent accidental overwriting and security featur es. the physical form factor, pin assignment and data transfer protocol are forward-compatible with the mmc with some additions. sd slots can actually be used for more than flash memory cards. devi ces that support sdio can use small devices designed for the sd form factor, such as gps re ceivers, wi-fi or bluetooth adapters, modems, barcode readers, irda adapters, fm radio tuners, rfid readers, digital cameras and more. sd/sdio is covered by numerous patents and trademarks, and licensing is only available through the secure digital card association. the sd/sdio card communication is based on a 9-pin interface (clock, command, 4 x data and 3 x power lines). the communication protocol is defined as a part of this specification. the main difference between the sd/sdio card and the mmc is the initialization process. the sd/sdio card register (sdcr) allows select ion of the card slot and the data bus width. the sd/sdio card bus allows dynamic configur ation of the number of data lines. after power up, by default, the sd/sdio card uses only dat0 for data transfer. after initialization, the host can change the bus width (number of active data lines). 30.7.3.1 sdio data transfer type sdio cards may transfer data in either a multi-byte (1 to 512 bytes) or an optional block format (1 to 511 blocks), while the sd memory cards are fixed in the block transfer mode. the trtyp field in the command register (cmdr) allows to choose between sdio byte or sdio block transfer. the number of bytes/blocks to transfer is set through the bcnt field in the block register (blkr). in sdio block mode, the field blklen must be set to the data block size while this field is not used in sdio byte mode. an sdio card can have multiple i/o or combined i/o and memo ry (called combo card). within a multi-function sdio or a combo card, there are multiple devices (i/o and memory) that share access to the sd bus. in order to allow the sharing of access to the host among multiple devices, sdio and combo cards can implement the optional concept of suspend/resume (refer to the sdio specification for more details). to send a suspend or a resume command, the host must set the sdio special command field (iospcmd) in the command register. 30.7.3.2 sdio interrupts each function within an sdio or combo card ma y implement interrupts (refer to the sdio spec- ification for more details). in order to allow the sdio card to interrupt the host, an interrupt function is added to a pin on the dat[1] line to si gnal the card?s interrupt to the host. an sdio interrupt on each slot can be enabled through the mci interrupt enable register. the sdio inter- rupt is sampled regardless of the currently selected slot.
579 32054f?avr32?09/09 at32ap7002 30.8 user interface note: 1. the response register can be read by n accesses at the same rspr or at consecutive addresses (0x20 to 0x2c). n depends on the size of the response. table 30-6. register mapping offset register register name read/write reset 0x00 control register cr write ? 0x04 mode register mr read/write 0x0 0x08 data timeout register dtor read/write 0x0 0x0c sd/sdio card register sdcr read/write 0x0 0x10 argument register argr read/write 0x0 0x14 command register cmdr write ? 0x18 block register blkr read/write ? 0x1c reserved ? ? ? 0x20 response register (1) rspr read 0x0 0x24 response register (1) rspr read 0x0 0x28 response register (1) rspr read 0x0 0x2c response register (1) rspr read 0x0 0x30 receive data register rdr read 0x0 0x34 transmit data register tdr write ? 0x38 - 0x3c reserved ? ? ? 0x40 status register sr read 0x25 0x44 interrupt enable register ier write ? 0x48 interrupt disable register idr write ? 0x4c interrupt mask register imr read 0x0 0x50-0xf8 reserved ? ? ? 0xfc version register version read-only ? 0x50-0xfc reserved ? ? ?
580 32054f?avr32?09/09 at32ap7002 30.8.1 control register name: cr access type: write-only offset: 0x00 reset value: ? ? swrst: software reset 0 = no effect. 1 = resets the mci. a software triggered hardware reset of the mci interface is performed. ? mcidis: multi-media interface disable 0 = no effect. 1 = disables the multi-media interface. ? mcien: multi-media interface enable 0 = no effect. 1 = enables the multi-media interface if mcdis is 0. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst??? ? mcidis mcien
581 32054f?avr32?09/09 at32ap7002 30.8.2 mode register name: mr access type: read/write offset: 0x04 reset value: 0x00000000 ? blklen: data block length this field determines the size of the data block. this field is also accessible in the mci block register (blkr). bits 16 and 17 must be written to 0 if pdcfbyte is disabled. note: in sdio byte mode, blklen field is not used. ? dmapadv: dma padding value 0 = 0x00 value is used when padding data in write transfer. 1 = 0xff value is used when padding data in write transfer. ? pdcfbyte: pdc force byte transfer enabling pdc force byte transfer allows the pdc to manage with internal byte transfers, so that transfer of blocks with a size different from modulo 4 can be supported. this applies to both pdc and non-pdc transfers. warning: blklen value depends on pdcfbyte. 0 = disables pdc force byte transfer. pdc type of transfer are in words. 1 = enables pdc force byte transfer. pdc type of transfer are in bytes. ? wrproof write proof enable enabling write proof allows to stop the mci clock during write ac cess if the internal fifo is full. this will guarantee data integrity, no t bandwidth. 0 = disables write proof. 1 = enables write proof. ? rdproof read proof enable enabling read proof allows to stop the mci clock during read acce ss if the internal fifo is full. this will guarantee data integrity, no t bandwidth. 0 = disables read proof. 1 = enables read proof. 31 30 29 28 27 26 25 24 blklen 23 22 21 20 19 18 17 16 blklen 15 14 13 12 11 10 9 8 - dmapadv pdcfbyte wrproof rdproof 76543210 clkdiv
582 32054f?avr32?09/09 at32ap7002 ? clkdiv: clock divider multimedia card interface clock (mcck) is mast er clock (clk_mci) divided by (2*(clkdiv+1)).
583 32054f?avr32?09/09 at32ap7002 30.8.3 data timeout register name: dtor access type: read/write offset: 0x08 reset value: 0x00000000 ? dtomul: data ti meout multiplier these fields determine the maximum number of master clock cycles that the mci waits between two data block transfers. it equals (dtocyc x multiplier). multiplier is defined by dtomul as shown in the following table: if the data time-out set by dtocyc and dtomul has been exceeded, the data time-out error flag (dtoe) in the mci status register (sr) raises. ? dtocyc: data timeout cycle number 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? dtomul dtocyc dtomul multiplier 0001 00116 010128 011256 1001024 1014096 1 1 0 65536 1 1 1 1048576
584 32054f?avr32?09/09 at32ap7002 30.8.4 sd card/sdio register name: sdcr access type: read/write offset: 0x0c reset value: 0x00000000 ? sdcbus: sd card/sdio bus width 0 = 1-bit data bus 1 = 4-bit data bus ? sdcsel: sd card selector 0 = sdcard slot a selected. 1= sdcard slot b selected. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 sdcbus????? sdcsel
585 32054f?avr32?09/09 at32ap7002 30.8.5 argument register name: argr access type: read/write offset: 0x10 reset value: 0x00000000 ? arg: command argument 31 30 29 28 27 26 25 24 arg 23 22 21 20 19 18 17 16 arg 15 14 13 12 11 10 9 8 arg 76543210 arg
586 32054f?avr32?09/09 at32ap7002 30.8.6 command register name: cmdr access type: write-only offset: 0x14 reset value: ? this register is write-protecte d while cmdrdy is 0 in sr. if an interrupt command is sent, this register is only writeable by an interrupt response (field spcmd). this means that the current command execution cannot be interrupted or modified. ? iospcmd: sdio special command ? trtyp: transfer type ? trdir: transfer direction 0 = write 1 = read 31 30 29 28 27 26 25 24 ?????? iospcmd 23 22 21 20 19 18 17 16 ? ? trtyp trdir trcmd 15 14 13 12 11 10 9 8 ? ? ? maxlat opdcmd spcmd 76543210 rsptyp cmdnb iospcmd sdio special command type 0 0 not a sdio special command 0 1 sdio suspend command 1 0 sdio resume command 11reserved trtyp transfer type 0 0 0 mmc/sdcard single block 0 0 1 mmc/sdcard multiple block 010mmc stream 0 1 1 reserved 1 0 0 sdio byte 101sdio block 1 1 0 reserved 1 1 1 reserved
587 32054f?avr32?09/09 at32ap7002 ? trcmd: transfer command ? maxlat: max latency for command to response 0 = 5-cycle max latency 1 = 64-cycle max latency ? opdcmd: open drain command 0 = push pull command 1 = open drain command ? spcmd: special command ? rsptyp: response type ? cmdnb: command number trcmd transfer type 0 0 no data transfer 0 1 start data transfer 1 0 stop data transfer 11reserved spcmd command 0 0 0 not a special cmd. 001 initialization cmd: 74 clock cycles for in itialization sequence. 010 synchronized cmd: wait for the end of the current data block transfer before sending the pending command. 011reserved. 100 interrupt command: corresponds to the interrupt mode (cmd40). 101 interrupt response: corresponds to the interrupt mode (cmd40). rsp response type 0 0 no response. 0 1 48-bit response. 1 0 136-bit response. 1 1 reserved.
588 32054f?avr32?09/09 at32ap7002 30.8.7 block register name: blkr access type: read/write offset: 0x00 reset value: ? ? blklen: data block length this field determines the size of the data block. this field is also accessible in the mci mode register (mr). bits 16 and 17 must be set to 0 if pdcfbyte is disabled. note: in sdio byte mode, blklen field is not used. ? bcnt: mmc/sdio block count - sdio byte count this field determines the number of data byte(s) or block(s) to transfer. the transfer data type and the authorized values for bcnt field are determined by the trtyp field in the mci command register (cmdr): warning: in sdio byte and block modes, writing to the 7 last bi ts of bcnt field, is forbidden and may lead to unpredict- able results. 31 30 29 28 27 26 25 24 blklen 23 22 21 20 19 18 17 16 blklen 15 14 13 12 11 10 9 8 bcnt 76543210 bcnt trtyp type of transfer bcnt authorized values 0 0 1 mmc/sdcard multiple block from 1 to mci_maxnum_blk: value 0 corresponds to an infinite block transfer. 1 0 0 sdio byte from 1 to 512 bytes: value 0 corresponds to a 512-byte transfer. values from 0x200 to 0xffff are forbidden. 1 0 1 sdio block from 1 to 511 blocks: value 0 corresponds to an infinite block transfer. values from 0x200 to 0xffff are forbidden. other values - reserved.
589 32054f?avr32?09/09 at32ap7002 30.8.8 response register name: rspr access type: read-only offset: 0x20 - 0x2c reset value: 0x00000000 ? rsp: response note: 1. the response register can be read by n accesses at the same rspr or at consecutive addresses (0x20 to 0x2c). n depends on the size of the response. 31 30 29 28 27 26 25 24 rsp 23 22 21 20 19 18 17 16 rsp 15 14 13 12 11 10 9 8 rsp 76543210 rsp
590 32054f?avr32?09/09 at32ap7002 30.8.9 receive data register name: rdr access type: read-only offset: 0x30 reset value: 0x00000000 ? data: data to read 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
591 32054f?avr32?09/09 at32ap7002 30.8.10 transmit data register name: tdr access type: write-only offset: 0x34 reset value: ? ? data: data to write 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
592 32054f?avr32?09/09 at32ap7002 30.8.11 status register name: sr access type: read-only offset: 0x40 reset value: 0x00000025 ? unre: underrun 0 = no error. 1 = at least one 8-bit data has been sent without valid inform ation (not written). cleared when sending a new data transfer command. ? ovre: overrun 0 = no error. 1 = at least one 8-bit received data has been lost (not read). cleared when sending a new data transfer command. ? dtoe: data time-out error 0 = no error. 1 = the data time-out set by dtocyc and dtomul in dtor has been exceeded. cleared when reading sr. ? dcrce: data crc error 0 = no error. 1 = a crc16 error has been detected in the last data block. cleared when reading sr. ? rtoe: response time-out error 0 = no error. 1 = the response time-out set by maxlat in the cmdr has been exceeded. cleared when writing in the cmdr. ? rende: response end bit error 0 = no error. 1 = the end bit of the response has not been detected. cleared when writing in the cmdr. ? rcrce: response crc error 0 = no error. 1 = a crc7 error has been detected in the response. cleared when writing in the cmdr. ? rdire: response direction error 0 = no error. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 ??????sdioirqbsdioirqa 76543210 ? ? notbusy dtip blke txrdy rxrdy cmdrdy
593 32054f?avr32?09/09 at32ap7002 1 = the direction bit from card to host in the response has not been detected. ? rinde: response index error 0 = no error. 1 = a mismatch is detected between the command index sent and the response index received. cleared when writing in the cmdr. ? sdioirqb: sdio interrupt for slot b 0 = no interrupt detected on sdio slot b. 1 = a sdio interrupt on slot b has reached. cleared when reading the sr. ? sdioirqa: sdio interrupt for slot a 0 = no interrupt detected on sdio slot a. 1 = a sdio interrupt on slot a has reached. cleared when reading the sr. ? notbusy: data not busy this flag must be used only for write operations. a block write operation uses a simple busy signalling of the write operat ion duration on the data (dat0) line: during a data transfer block, if the card does not have a free data receive buffer, the card indicates this condition by pulling down the dat a line (dat0) to low. the card stops pulling down the data line as soon as at least one receive buffer for the defined data transfer block length becomes free. the notbusy flag allows to deal with these different states. 0 = the mci is not ready for new data transfer. cleared at the end of the card response. 1 = the mci is ready for new data transfer. set when the busy state on the data line has ended. this corresponds to a free internal data receive buffer of the card. refer to the mmc or sd specification for more details concerning the busy behavior. ? dtip: data transfer in progress 0 = no data transfer in progress. 1 = the current data tran sfer is still in progress, including crc16 calculatio n. cleared at the end of the crc16 calculation. ? blke: data block ended this flag must be used only for write operations. 0 = a data block transfer is not yet finished. cleared when reading the sr. 1 = a data block transfer has ended, including the crc16 status transmission. the flag is set for each transmitted crc status. refer to the mmc or sd sp ecification for more details concerning the crc status. ? txrdy: transmit ready 0= the last data written in tdr has not yet been transferred in the shift register. 1= the last data written in tdr has been transferred in the shift register. ? rxrdy: receiver ready 0 = no data has been received since the last read of rdr. 1 = data has been received since the last read of rdr.
594 32054f?avr32?09/09 at32ap7002 ? cmdrdy: command ready 0 = a command is in progress. 1 = the last command has been sent. cleared when writing in the cmdr.
595 32054f?avr32?09/09 at32ap7002 30.8.12 interrupt enable register name: ier access type: write-only offset: 0x44 reset value: ? ? unre: underrun interrupt enable ? ovre: overrun in terrupt enable ? dtoe: data time-out error interrupt enable ? dcrce: data crc error interrupt enable ? rtoe: response time-out error interrupt enable ? rende: response end bit error interrupt enable ? rcrce: response crc error interrupt enable ? rdire: response direction error interrupt enable ? rinde: response index er ror interrupt enable ? sdioirqb: sdio interrupt for slot b interrupt enable ? sdioirqa: sdio interrupt for slot a interrupt enable ? notbusy: data not busy interrupt enable ? dtip: data transfer in progress interrupt enable ? blke: data block ended interrupt enable ? txrdy: transmit ready interrupt enable ? rxrdy: receiver ready interrupt enable ? cmdrdy: command ready interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 ??????sdioirqbsdioirqa 76543210 ? ? notbusy dtip blke txrdy rxrdy cmdrdy
596 32054f?avr32?09/09 at32ap7002 30.8.13 interrupt disable register name: idr access type: write-only offset: 0x48 reset value: ? ? unre: underrun interrupt disable ? ovre: overrun in terrupt disable ? dtoe: data time-out er ror interrupt disable ? dcrce: data crc error interrupt disable ? rtoe: response time-out error interrupt disable ? rende: response end bit error interrupt disable ? rcrce: response crc error interrupt disable ? rdire: response direction error interrupt disable ? rinde: response index er ror interrupt disable ? sdioirqb: sdio interrupt for slot b interrupt enable ? sdioirqa: sdio interrupt for slot a interrupt enable ? notbusy: data not busy interrupt disable ? dtip: data transfer in progress interrupt disable ? blke: data block ended interrupt disable ? txrdy: transmit ready interrupt disable ? rxrdy: receiver ready interrupt disable ? cmdrdy: command ready interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 ??????sdioirqbsdioirqa 76543210 ? ? notbusy dtip blke txrdy rxrdy cmdrdy
597 32054f?avr32?09/09 at32ap7002 30.8.14 interrupt mask register name: imr access type: read-only offset: 0x4c reset value: 0x00000000 ? unre: underrun interrupt mask ? ovre: overrun interrupt mask ? dtoe: data time-out error interrupt mask ? dcrce: data crc error interrupt mask ? rtoe: response time-out error interrupt mask ? rende: response end bit error interrupt mask ? rcrce: response crc error interrupt mask ? rdire: response directio n error interrupt mask ? rinde: response index error interrupt mask ? sdioirqb: sdio interrupt for slot b interrupt enable ? sdioirqa: sdio interrupt for slot a interrupt enable ? notbusy: data not busy interrupt mask ? dtip: data transfer in progress interrupt mask ? blke: data block ended interrupt mask ? txrdy: transmit ready interrupt mask ? rxrdy: receiver ready interrupt mask ? cmdrdy: command ready interrupt mask 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 ??????sdioirqbsdioirqa 76543210 ? ? notbusy dtip blke txrdy rxrdy cmdrdy
598 32054f?avr32?09/09 at32ap7002 31. hi-speed usb interface (usba) rev: 1.4.0.2 31.1 features ? supports hi (480mbps) and full (12mbps) speed communication ? compatible with the usb 2.0 specification ? utmi compliant ? 7 endpoints ? embedded dual-port ram for endpoints ? suspend/resume logic (command of utmi) ? up to three memory banks for endpoints (not for control endpoint) ? 4 kbytes of dpram 31.2 description the usb high speed device (usba) is compliant with the universal serial bus (usb), rev 2.0 high speed device specification. each endpoint can be configured in one of several usb transfer types. it can be associated with one, two or three banks of a dual-port ram used to store the current data payload. if two or three banks are used, one dpr bank is read or written by the processor, while the other is read or written by the usb device peripheral. this f eature is mandatory for isochronous endpoints. the default size of the dpram is 4 kb. suspend and resume are automatically detected by the usba device, which notifies the proces- sor by raising an interrupt. table 31-1. usba endpoint description endpoint # mnemonic nb bank dma high band width max. endpoint size endpoint type offset 0 ep0 1 n n 64 control 0x00000 1 ep1 2 y y 512 ctrl/bulk/iso/interrupt 0x10000 2 ep2 2 y y 512 ctrl/bulk/iso/interrupt 0x20000 3 ep3 3 y n 64 ctrl/bulk/interrupt 0x30000 4 ep4 3 y n 64 ctrl/bulk/interrupt 0x40000 5 ep5 3 y y 1024 ctrl/bulk/iso/interrupt 0x50000 6 ep6 3 y y 1024 ctrl/bulk/iso/interrupt 0x60000
599 32054f?avr32?09/09 at32ap7002 31.3 block diagram figure 31-1. block diagram: 31.4 product dependencies 31.4.1 power management the usba clock is generated by the power manager. before using the usba, the programmer must ensure that the usba clock is enabled in the power manager. to prevent bus errors the u sba operation must be terminat ed before entering sleep mode. the usb hs phy clock has to be enabled before using the usba. the description of this clock can be found in the peripherals chapter under clock connections. 31.4.2 interrupt the usba interface has an interr upt line connected to the inte rrupt controller. handling the usba interrupt require s programming the inte rrupt controller before configuring the usba. 32 bits system clock domain usb clock domain ctrl status rd/wr/ready peripheral bus interface usb2.0 core ept alloc hsb1 dma hsb0 local hsb slave interface master hsb multiplexer slave dpram utmi 16/8 bits pb bus hsb bus hsb bus
600 32054f?avr32?09/09 at32ap7002 31.5 typical connection figure 31-2. board schematic table 31-2. components typical values symbol value unit r1 6.8 1% k r2 39 1% c1 10 pf hsdp hsdm fsdm fsdp bias r2 r2 r1 c1 d- d+
601 32054f?avr32?09/09 at32ap7002 31.6 usb v2.0 high speed device introduction the usb v2.0 high speed device provides communication services to/from host when attached. each device is offered with a collection of communication flows (pipes) associated with each endpoint. software on the host communicates with a usb device through a set of commu- nication flows. 31.6.1 usb v2.0 high speed transfer types a communication flow is carried over one of f our transfer types defined by the usb device. a device provides several logical communication pipes with the host. to each logical pipe is associated an endpoint. transfer through a pipe belongs to one of the four transfer types: ? control transfers: used to configure a device at attach time and can be used for other device- specific purposes, including control of other pipes on the device. ? bulk data transfers: generated or consumed in relatively large burst quantities and have wide dynamic latitude in transmission constraints. ? interrupt data transfers: used for timely but reliable delivery of data, for example, characters or coordinates with human-perceptible echo or feedback response characteristics. ? isochronous data transfers: occupy a prenegotiated amount of usb bandwidth with a prenegotiated delivery latency. (also called streaming real time transfers.) as indicated below, transfers are sequential events carried out on the usb bus. endpoints must be configured according to the transfer type they handle. table 31-3. usb communication flow transfer direction bandwidth endpoin t size error detection retrying control bidirectional not guaranteed 8,16,32,64 yes automatic isochronous unidirectional guaranteed 8-1024 yes no interrupt unidirectional not guaranteed 8-1024 yes yes bulk unidirectional not guaranteed 8-512 yes yes
602 32054f?avr32?09/09 at32ap7002 31.6.2 usb transfer event definitions a transfer is composed of one or several transactions; notes: 1. control transfer must use endpoints with one bank and can be aborted using a stall handshake. 2. isochronous transfers must use endpoint s configured with two or three banks. an endpoint handles all transactions related to the type of transfer for which it has been configured. 31.6.3 usb v2.0 high speed bus transactions each transfer results in one or more transactions over the usb bus. there are five kinds of transactions flowing across the bus in packets: 1. setup transaction 2. data in transaction 3. data out transaction 4. status in transaction 5. status out transaction table 31-4. usb transfer events control (bidirectional) control transfers (1) ? setup transaction > data in transactions > status out transaction ? setup transaction > data out tran sactions > status in transaction ? setup transaction > st atus in transaction in (device toward host) bulk in transfer ? data in transaction > data in transaction interrupt in transfer ? data in transaction > data in transaction isochronous in transfer (2) ? data in transaction > data in transaction out (host toward device) bulk out transfer ? data out transaction > data out transaction interrupt out transfer ? data out transaction > data out transaction isochronous out transfer (2) ? data out transaction > data out transaction
603 32054f?avr32?09/09 at32ap7002 figure 31-3. control read and write sequences a status in or out transaction is identical to a data in or out transaction. 31.6.4 endpoint configuration the endpoint 0 is always a control endpoint, it must be programmed and active in order to be enabled when the end of reset interrupt occurs. to configure the endpoints: ? fill the configuration register (eptcfg) with th e endpoint size, direction (in or out), type (ctrl, bulk, it, iso) and the number of banks. ? fill the number of transactions (n b_trans) for isochronous endpoints. note: for control endpoints the direction has no effect. ? verify that the ept_mapd flag is set. this flag is set if the endpoint size and the number of banks are correct compared to the fifo maximum capacity and the maximum number of allowed banks. ? configure control flags of the endpoint and enable it in eptctlenbx according to ?usba endpoint control register? on page 654 . control endpoints can generate interrupts and use only 1 bank. all endpoints (except endpoint 0) can be configur ed either as bulk, interrupt or isochronous. see table 31-1. usba endp oint description . the maximum packet size they can accept corresponds to the maximum endpoint size. note: the endpoint size of 1024 is reserved for isochronous endpoints. the size of the dpram is 4 kb. the dpr is shared by all active endpoints. the memory size required by the active endpoints must not exceed the size of the dpram. control write setup tx data out tx data out tx data stage control read setup stage setup stage setup tx setup tx no data control data in tx data in tx status stage status stage status in tx status out tx status in tx data stage setup stage status stage
604 32054f?avr32?09/09 at32ap7002 size_dpram = size _ept0 + nb_bank_ept1 x size_ept1 + nb_bank_ept2 x size_ept2 + nb_bank_ept3 x size_ept3 + nb_bank_ept4 x size_ept4 + nb_bank_ept5 x size_ept5 + nb_bank_ept6 x size_ept6 +... (refer to 31.7.17 usba endpoint configuration register ) if a user tries to configure endpoints with a size the sum of which is greater than the dpram, then the ept_mapd is not set. the application has access to the physical block of dpr reserved for the endpoint through a 64 kb logical address space. the physical block of dpr allocated for the endpoint is remapped all along the 64 kb logical address space. the application can write a 64 kb buffer linearly. figure 31-4. logical address space for dpr access: configuration examples of eptctlx ( usba endpoint control register ) for bulk in endpoint type follow below. 64 kb ep0 64 kb ep1 64 kb ep2 dpr logical address 8 to 64 b 8 to1024 b 8 to1024 b 8 to1024 b 64 kb ep3 ... 8 to 64 b 8 to 64 b 8 to 64 b ... ... x banks y banks z banks 8 to1024 b 8 to1024 b 8 to1024 b
605 32054f?avr32?09/09 at32ap7002 ?with dma ? auto_valid: automatically validate the packet and switch to the next bank. ? ept_enabl: enable endpoint. ? without dma: ? tx_bk_rdy: an interrupt is generated after each transmission. ? ept_enabl: enable endpoint. configuration examples of bulk out endpoint type follow below. ?with dma ? auto_valid: automatically validate the packet and switch to the next bank. ? ept_enabl: enable endpoint. ? without dma ? rx_bk_rdy: an interrupt is sent after a new packet has been stored in the endpoint fifo. ? ept_enabl: enable endpoint.
606 32054f?avr32?09/09 at32ap7002 31.6.5 dma usb packets of any length may be transferred wh en required by the usba device. these trans- fers always feature sequential addressing. packet data hsb bursts may be locked on a dma buffer basis for drastic overall hsb bus band- width performance boost with pa ged memories. these clock-cycl e consuming memory row (or bank) changes will then likely not occur, or occu r only once instead of dozens times, during a single big usb packet dma transfer in case another hsb master addresses the memory. this means up to 128-word single-cycle unbroken hsb bursts for bulk endpoints and 256-word sin- gle-cycle unbroken bursts for isochronous endpo ints. this maximum burst length is then controlled by the lowest programmed usb endpoint size (ept_size bit in the eptcfgx regis- ter) and dma size (buff_length bit in the dmacontrolx register). the usba device average throughput may be up to near ly 60 mbytes. its in ternal slave average access latency decreases as burst length incr eases due to the 0 wait-state side effect of unchanged endpoi nts. if at least 0 wait-state word burst capability is also pr ovided by the exter- nal dma hsb bus slaves, each of both dm a hsb busses need less than 50% bandwidth allocation for full usba bandwi dth usage at 30 mh z, and less than 25% at 60 mhz. the usba dma channel transfer descriptor is described in ?usba dma channel transfer descriptor? on page 665 figure 31-5. example of dma chained list: 31.6.6 handling transactions with usb v2.0 device peripheral 31.6.6.1 setup transaction the setup packet is valid in the dpr while rx_s etup is set. once rx_setup is cleared by the application, the usba ac cepts the next packets sent over the device endpoint. data buff 1 data buff 2 data buff 3 memory area transfer descriptor next descriptor address dma channel address dma channel control transfer descriptor next descriptor address dma channel address dma channel control transfer descriptor next descriptor address dma channel address dma channel control udphs registers (current transfer descriptor) udphs next descriptor dma channel address dma channel control null
607 32054f?avr32?09/09 at32ap7002 when a valid setup packet is accepted by the usba: ? the usba device automatically acknowledges the setup packe t (sends an ack response) ? payload data is written in the endpoint ? sets the rx_setup interrupt ? the byte_count field in the ept stax register is updated an endpoint interrupt is generated while rx_setup in the eptstax register is not cleared. this interrupt is carried out to the microcontroller if interrupts are enabled for this endpoint. thus, firmware must detect rx_setup pollin g eptstax or catching an interrupt, read the setup packet in the fifo, then clear the rx_set up bit in the eptclrsta register to acknowl- edge the setup stage. if stall_snt was set to 1, then this bit is automatically reset when a setup token is detected by the device. then, the device still accepts the setup stage. (see section 31.6.6.15 ?stall? on page 618 ). 31.6.6.2 nyet nyet is a high speed only handshake. it is retu rned by a high speed endpoint as part of the ping protocol. high speed devices must support an improved nak mechanism for bulk out and control end- points (except setup stage). this mechanism allows the device to tell the host whether it has sufficient endpoint space for the next out transfe r (see usb 2.0 spec 8.5.1 nak limiting via ping flow control). the nyet/ack response to a high speed bulk out transfer and the ping response are auto- matically handled by hardware in the eptctlx register (except when the user wants to force a nak response by using the nyet_dis bit). if the endpoint responds instead to the out/data transaction with an nyet handshake, this means that the endpoint accepted the data but does not have room for another data payload. the host controller must return to using a ping token until the endpoint indicates it has space available. figure 31-6. nyet example with two endpoint banks t = 0 t = 125 s t = 250 s t = 375 s t = 500 s t = 625 s data 0 ack data 1 nyet ping ack data 0 nyet ping nack ping ack bank 1 bank 0 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 e f f e f e' f e f f e' f e f e: empty e': begin to empty f: full
608 32054f?avr32?09/09 at32ap7002 31.6.6.3 data in 31.6.6.4 bulk in or interrupt in data in packets are sent by the device during the data or the status stage of a control transfer or during an (interrupt/bulk/isochronous) in transfer. data buffers are sent packet by packet under the control of the application or under the control of the dma channel. there are three ways for an application to transfer a buffer in several packets over the usb: ? packet by packet (see 31.6.6.5 below) ? 64 kb (see 31.6.6.5 below) ?dma (see 31.6.6.6 below) 31.6.6.5 bulk in or interrupt in: sending a packet under application control (device to host) the application can write one or several banks. a simple algorithm can be used by the application to send packets regardless of the number of banks associated to the endpoint. algorithm description for each packet: ? the application waits for tx_pk_rdy flag to be cleared in the eptstax register before it can perform a write access to the dpr. ? the application writes one usb packet of data in the dpr through the 64 kb endpoint logical memory window. ? the application sets tx_pk_rdy flag in the eptsetstax register. the application is notified that it is possible to write a new packet to the dpr by the tx_pk_rdy interrupt. this interrupt can be enabled or masked by setting the tx_pk_rdy bit in the eptctlenb/eptctldis register. algorithm description to fill several packets: using the previous algorithm, the application is interrupted for each packet. it is possible to reduce the application overhead by writing linearly several banks at the same time. the auto_valid bit in the eptctlx must be set by writing the auto_valid bit in the eptctlenbx register. the auto-valid-bank mechanism allows the transfer of data (in and out) without the interven- tion of the cpu. this means that bank validation (set tx_pk_rdy or clear the rx_bk_rdy bit) is done by hardware. ? the application checks the busy_bank_sta field in the eptstax register. the application must wait that at least one bank is free. ? the application writes a number of bytes inferior to the number of free dpr banks for the endpoint. each time the application writes the last byte of a bank, the tx_pk_rdy signal is automatically set by the usba. ? if the last packet is incomplete (i.e., the last byte of the bank has not been written) the application must set th e tx_pk_rdy bit in the eptsetstax register. the application is notified that all banks are free, so that it is possible to write another burst of packets by the busy_bank interrupt. this interrupt can be enabled or masked by setting the busy_bank flag in the eptctlenb and eptctldis registers.
609 32054f?avr32?09/09 at32ap7002 this algorithm must not be used for isochronous transfer. in this case, the ping-pong mechanism does not operate. a zero length packet can be sent by setting just the tx_pktrdy flag in the eptsetstax register. 31.6.6.6 bulk in or interrupt in: sending a buffer using dma (device to host) the usba integrates a dma host controller. this dma controller can be used to transfer a buf- fer from the memory to the dpr or from the dpr to the processor memory under the usba control. the dma can be used for all transfer types except control transfer. example dma configuration: 1. program dmaaddressx with the address of the buffer that should be transfer. 2. enable the interrupt of the dma in ien 3. program dmacontrolx: ? size of buffer to send: size of the buffer to be sent to the host. ? end_b_en: the endpoint can validate the packet (according to the values programmed in the auto_valid and shrt_pckt fields of eptctlx.) (see ?usba endpoint control register? on page 654 and figure 31-11. autovalid with dma ) ? end_buffit: generate an interrup t when the buff_count in dmastatusx reaches 0. ? chann_enb: run and stop at end of buffer the auto-valid-bank mechanism allows the transfer of data (in & out) without the intervention of the cpu. this means that bank validation (s et tx_pk_rdy or clear the rx_bk_rdy bit) is done by hardware. a transfer descriptor can be used. instead of programming the register directly, a descriptor should be programmed and the address of this descriptor is then given to dmanxtdsc to be processed after setting the ldnxt_dsc field (load next descriptor now) in dmacontrolx register. the structure that defines this transfer descriptor must be aligned. each buffer to be transferred must be described by a dma transfer descriptor (see ?usba dma channel transfer descriptor? on page 665 ). transfer descriptors are chained. before executing transfer of the buffer, the usba may fetch a new transfer descriptor from the memory address pointed by the dmanxtdscx register. once the transfer is complete, the transfer status is updated in the dmastatusx register. to chain a new transfer descriptor with the current dma transfer, the dma channel must be stopped. to do so, intdis_dma and tx_bk_rdy may be set in the eptctlenbx register. it is also possible for the application to wait for the completion of all transfers. in this case the ldnxt_dsc field in the last tr ansfer descriptor dmacontrolx register must be set to 0 and chann_enb set to 1. then the application can chain a new transfer descriptor. the intdis_dma can be used to stop the current dma transfer if an enabled interrupt is trig- gered. this can be used to stop dma transfers in case of errors. the application can be notified at the end of any buffer transfer (enb_buffit bit in the dma- controlx register).
610 32054f?avr32?09/09 at32ap7002 figure 31-7. data in transfer for endpoint with one bank figure 31-8. data in transfer for endpoint with two banks usb bus packets fifo content tx_complt flag (udphs_eptstax) tx_pk_rdy flag (udphs_eptstax) prevous data in tx microcontroller loads data in fifo data is sent on usb bus interrupt pending set by firmware cleared by hardware set by the firmware cleared by hardware interrupt pending cleared by firmware dpr access by firmware dpr access by hardware cleared by firmware payload in fifo set by hardware data in 2 token in nak ack data in 1 token in token in ack data in 1 load in progress data in 2 read by usb device read by udphs device fifo (dpr) bank 0 tx_complt flag (udphs_eptstax) interrupt cleared by firmware virtual tx_pk_rdy bank 1 (udphs_eptstax) ack token in ack set by firmware, data payload written in fifo bank 1 cleared by hardware data payload fully transmitted token in usb bus packets set by hardware set by hardware set by firmware, data payload written in fifo bank 0 written by fifo (dpr) bank1 microcontroller written by microcontroller written by microcontroller microcontroller load data in bank 0 microcontroller load data in bank 1 udphs device send bank 0 microcontroller load data in bank 0 udphs device send bank 1 interrupt pending data in data in cleared by hardware switch to next bank virtual tx_pk_rdy bank 0 (udphs_eptstax)
611 32054f?avr32?09/09 at32ap7002 figure 31-9. data in followed by status out transfer at the end of a control transfer note : a nak handshake is always generated at the first status stage token. figure 31-10. data out followed by status in transfer note : before proceeding to the status stage, the software should determine that there is no risk of extra data from the host (data stage). if not certain (non-predictable data stage length), then the software should wait for a nak-in interrupt before proceeding to the status stage. this pre- caution should be taken to av oid collision in the fifo. token out data in token in ack ack data out (zlp) rx_bk_rdy (udphs_eptstax) tx_complt (udphs_eptstax) set by hardware set by hardware usb bus packets cleared by firmware cleared by firmware device sends a status out to host device sends the last data payload to host interrupt pending token out ack data out (zlp) token in ack data out token out ack data in usb bus packets rx_bk_rdy (udphs_eptstax) cleared by firmware set by hardware clear by hardware tx_pk_rdy (udphs_eptstax) set by firmware host sends the last data payload to the device device sends a status in to the host interrupt pending
612 32054f?avr32?09/09 at32ap7002 figure 31-11. autovalid with dma note: in the illustration above autovalid validates a bank as full, although this might not be the case, in order to continue pr ocessing data and to send to dma. 31.6.6.7 isochronous in isochronous-in is used to transmit a stream of data whose timing is implied by the delivery rate. isochronous transfer provides periodic, continuous communication between host and device. it guarantees bandwidth and low latencies appropriate for telephony, audio, video, etc. if the endpoint is not available (tx_pk_rdy = 0), then the device does not answer to the host. an err_fl_iso interrupt is generated in the eptstax register and once enabled, then sent to the cpu. the stall_snt command bit is not used for an iso-in endpoint. bank 0 bank 1 bank 0 bank (usb) write write bank 0 write bank 1 write bank 0 bank 0 bank (system) bank 1 bank 0 bank 1 virtual tx_pk_rdy bank 0 virtual tx_pk_rdy bank 1 tx_pk_rdy (virtual 0 & virtual 1) bank 0 is full bank 1 is full bank 0 is full in data 0 in data 1 in data 0 bank 1 bank 1 bank 0
613 32054f?avr32?09/09 at32ap7002 31.6.6.8 high bandwidth isochronous endpoint handling: in example for high bandwidth isochronous endpoints, the dma can be programmed with the number of transactions (buff_length field in dmacontrolx) and the system should provide the required number of packets per microfra me, otherwise, the host will notice a sequencing problem. a response should be made to the first token in recognized inside a microframe under the fol- lowing conditions: ? if at least one bank has been validated, the correct datax corresponding to the programmed number of transactions per microframe (nb_trans) should be answered. in case of a subsequent missed or co rrupted token in inside the microf rame, the usba core available data bank(s) that should normally have been transmitted during that microframe shall be flushed at its end. if this flush occurs, an error condit ion is flagged (err_flush is set in eptstax). ? if no bank is validated yet, the default data0 zlp is answered and underflow is flagged (err_fl_iso is set in eptstax). then, no data bank is flushed at microframe end. ? if no data bank has been validated at the time when a response should be made for the second transaction of nb_trans = 3 transactions microframe, a data1 zlp is answered and underflow is flagged (err_fl_iso is set in eptstax). if and only if remaining untransmitted banks for that microframe are available at its end, they are flushed and an error condition is flagged (err_flush is set in eptstax). ? if no data bank has been validated at the time when a response should be made for the last programmed transaction of a microframe, a data0 zlp is answered and underflow is flagged (err_fl_iso is set in eptstax). if and only if the remaining untransmitted data bank for that microframe is available at its end, it is flushed and an error condition is flagged (err_flush is set in eptstax). ? if at the end of a microframe no valid token in has been recognized, no data bank is flushed and no error condition is reported. at the end of a microframe in which at least one data bank has been transmitted, if less than nb_trans banks have been validated for that microframe, an error condition is flagged (err_trans is set in eptstax). cases of error (in eptstax) ? err_fl_iso: there was no data to transmit inside a microframe, so a zlp is answered by default. ? err_flush: at least one packet has been sent inside the microframe, but the number of token in received is lesser than the number of transactions actually validated (tx_bk_rdy) and likewise with the nb_trans programmed. ? err_trans: at least one packet has been sent inside the microframe, but the number of token in received is lesser than the number of programmed nb_trans transactions and the packets not requested were not validated. ? err_fl_iso + err_flush: at least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token in. ? err_fl_iso + err_trans: at least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token in and the data can be discarded at the microframe end.
614 32054f?avr32?09/09 at32ap7002 ? err_flush + err_trans: the first token in has been answered and it was the only one received, a second bank has been validated but not the third, whereas nb_trans was waiting for three transactions. ? err_fl_iso + err_flush + err_trans: the first token in has been treated, the data for the second token in was not available in time, but the second bank has been validated before the end of the microframe. the third bank has not been validated, but three transactions have been set in nb_trans. 31.6.6.9 data out 31.6.6.10 bulk out or interrupt out like data in, data out packets are sent by the host during the data or the status stage of con- trol transfer or during an interrupt/bulk/isochronous out transfer. data buffers are sent packet by packet under the control of the application or under the control of the dma channel. 31.6.6.11 bulk out or interrupt out: receiving a packet under application control (host to device) algorithm description for each packet: ? the application enables an interrupt on rx_bk_rdy. ? when an interrupt on rx_bk_rdy is received, the application knows that eptstax register byte_count bytes have been received. ? the application reads the byte_count bytes from the endpoint. ? the application clears rx_bk_rdy. note: if the application does not know the size of the transfer, it may not be a good option to use auto_valid. because if a zero-length-packet is received, the rx_bk_rdy is automatically cleared by the auto_valid hardwa re and if the endpoint interrupt is triggered, the software will not find its originating flag when reading the eptstax register. algorithm to fill several packets: ? the application enables the interrupts of busy_bank and auto_valid. ? when a busy_bank interrupt is received, the application knows that all banks available for the endpoint have be en filled. thus, the application can read all banks available. if the application doesn?t know the size of t he receive buffer, instead of using the busy_bank interrupt, the application must use rx_bk_rdy. 31.6.6.12 bulk out or interrupt out: sending a buffer using dma (host to device) to use the dma setting, the auto_valid field is mandatory. see 31.6.6.6 bulk in or interrupt in: sending a buffer using dma (device to host) for more information. dma configuration example: 1. first program dmaaddressx with the address of the buffer that should be transferred. 2. enable the interrupt of the dma in ien 3. program the dma channe lx control register: ? size of buffer to be sent. ? end_b_en: can be used for out packet truncation (discarding of unbuffered packet data) at the end of dma buffer.
615 32054f?avr32?09/09 at32ap7002 ? end_buffit: generate an interrup t when buff_count in the dmastatusx register reaches 0. ? end_tr_en: end of transfer enable, the usba device can put an end to the current dma transfer, in case of a short packet. ? end_tr_it: end of transfer interrupt enable, an interrupt is sent after the last usb packet has been transferred by the dma, if the usb transfer ended with a short packet. (beneficial when the receive size is unknown.) ? chann_enb: run and stop at end of buffer. for out transfer, the bank will be automatical ly cleared by hardware when the application has read all the bytes in the bank (the bank is empty). note: when a zero-length-packet is received, rx_bk_rdy bit in eptstax is cleared automat- ically by auto_valid, and the application knows of the end of buffer by the presence of the end_tr_it. note: if the host sends a zero-length packet, and the endpoint is free, then the device sends an ack. no data is written in the endpoint, the rx_by_rdy interrupt is generated, and the byte_count field in eptstax is null. figure 31-12. data out transfer for endpoint with one bank ack token out nak token out ack token out data out 1 usb bus packets rx_bk_rdy set by hardware cleared by firmware, data payload written in fifo fifo (dpr) content written by udphs device microcontroller read data out 1 data out 1 data out 2 host resends the next data payload microcontroller transfers data host sends data payload data out 2 data out 2 host sends the next data payload written by udphs device (udphs_eptstax) interrupt pending
616 32054f?avr32?09/09 at32ap7002 figure 31-13. data out transfer for an endpoint with two banks 31.6.6.13 high bandwidth isochronous endpoint out figure 31-14. bank management, example of three transactions per microframe usb 2.0 supports individual high speed isochronous endpoints that require data rates up to 192 mb/s (24 mb/s): 3x1024 data bytes per microframe. to support such a rate, two or three banks ma y be used to buffer the three consecutive data packets. the microcontroller (or the dma) should be able to empty the banks very rapidly (at least 24 mb/s on average). nb_trans field in eptcfgx register = number of transactions per microframe. if nb_trans > 1 then it is high bandwidth. token out ack data out 3 token out data out 2 token out data out 1 data out 1 data out 2 data out 2 ack cleared by firmware usb bus packets virtual rx_bk_rdy bank 0 virtual rx_bk_rdy bank 1 set by hardware data payload written in fifo endpoint bank 1 fifo (dpr) bank 0 bank 1 write by udphs device write in progress read by microcontroller read by microcontroller set by hardware, data payload written in fifo endpoint bank 0 host sends first data payload microcontroller reads data 1 in bank 0, host sends second data payload microcontroller reads data 2 in bank 1, host sends third data payload cleared by firmware write by hardware fifo (dpr) (udphs_eptstax) interrupt pending interrupt pending rx_bk_rdy = (virtual bank 0 | virtual bank 1) data out 1 data out 3 m data 0 m data 0 m data 1 data 2 data 2 m data 1 t = 0 t = 52.5 s (40% of 125 s) rx_bk_rdy t = 125 s rx_bk_rdy usb line read bank 3 read bank 2 read bank 1 read bank 1 usb bus transactions microcontroller fifo (dpr) access
617 32054f?avr32?09/09 at32ap7002 example: ? if nb_trans = 3, the sequence should be either ?mdata0 ? mdata0/data1 ? mdata0/data1/data2 ? if nb_trans = 2, the sequence should be either ?mdata0 ? mdata0/data1 ? if nb_trans = 1, the sequence should be ? data0 31.6.6.14 isochronous endpoint handling: out example the user can ascertain the bank status (free or busy), and the toggle sequencing of the data packet for each bank with the eptstax regi ster in the three bit fields as follows: ? togglesq_sta: pid of the data stored in the current bank ? current_bank: number of the bank currently being accessed by the microcontroller. ? busy_bank_sta: number of busy bank this is particularly useful in case of a missing data packet. if the inter-packet delay between the out token and the data is greater than the usb standard, then the iso-out transaction is ignored. (payload data is not written, no interrupt is generated to the cpu.) if there is a data crc (cyclic redundancy check) error, the payload is, none the less, written in the endpoint. the err_criso flag is set in eptstax register. if the endpoint is already full, the packet is not written in the dpram. the err_fl_iso flag is set in eptstax. if the payload data is greater than the maximum size of the endpoint, then the err_ovflw flag is set. it is the task of the cpu to manage this error. the data packet is written in the endpoint (except the extra data). if the host sends a zero length packet, and the endpoint is free, no data is written in the end- point, the rx_bk_rdy flag is set, and the byte_ count field in eptstax register is null. the frcestall command bit is unused for an isochonous endpoint. otherwise, payload data is written in the endpoint, the rx_bk_rdy interrupt is generated and the byte_count in eptstax register is updated.
618 32054f?avr32?09/09 at32ap7002 31.6.6.15 stall stall is returned by a function in response to an in token or after the data phase of an out or in response to a ping transaction. stall indicates that a function is unable to transmit or receive data, or that a control pipe request is not supported. ?out to stall an endpoint, set the frcestall bit in eptsetstax register and after the stall_snt flag has been set, set the toggle_seg bit in the eptclrstax register. ?in set the frcestall bit in eptsetstax register. figure 31-15. stall handshake data out transfer figure 31-16. stall handshake data in transfer token out stall pid data out usb bus packets cleared by firmware set by firmware frcestall stall_snt set by hardware interrupt pending cleared by firmware token in stall pid usb bus packets cleared by firmware set by firmware frcestall stall_snt set by hardware cleared by firmware interrupt pending
619 32054f?avr32?09/09 at32ap7002 31.6.7 speed identification the high speed reset is managed by the hardware. at the connection, the host makes a reset which could be a classic reset (full speed) or a high speed reset. at the end of the re set process (full or high), the endreset interrupt is generated. then the cpu should read the speed bit in intstax to ascertain the speed mode of the device. 31.6.8 usb v2.0 high speed global interrupt interrupts are defined in section 31.7.3 ?usba interr upt enable register? (ien) and in section 31.7.4 ?usba interrup t status register? (intsta). 31.6.9 endpoint interrupts interrupts are enabled in ien (see section 31.7.3 ?usba inte rrupt enable register? ) and individ- ually masked in eptctlenbx (see section 31.7.18 ?usba endpoint control enable register? ). table 31-5. endpoint interrupt source masks shrt_pckt short packet interrupt busy_bank busy bank interrupt nak_out nakout interrupt nak_in/err_flush nakin/error flush interrupt stall_snt/err_criso/err_nb_tra stall sent/crc e rror/number of transaction error interrupt rx_setup/err_fl_iso received setup/error flow interrupt tx_pk_rd /err_trans tx packet read/transaction error interrupt tx_complt transmitted in da ta complete interrupt rx_bk_rdy received out data interrupt err_ovflw overflow error interrupt mdata_rx mdata interrupt datax_rx datax interrupt
620 32054f?avr32?09/09 at32ap7002 figure 31-17. usba interrupt control interface det_suspd micro_sof ien_sof endreset wake_up endofrsm upstr_res usb global it sources ept0 it sources busy_bank nak_out (udphs_eptctlenbx) nak_in/err_flush stall_snt/err_criso/err_nb_tra rx_setup/err_fl_iso tx_bk_rdy/err_trans tx_complt rx_bk_rdy err_ovflw mdata_rx datax_rx (udphs_ien) ept1-6 it sources global it mask global it sources ep mask ep sources (udphs_ien) ept_int_0 ep mask ep sources (udphs_ien) ept_int_x (udphs_eptctlx) int_dis_dma dma ch x (udphs_dmacontrolx) en_buffit end_tr_it desc_ld_it mask mask mask (udphs_ien) dma_int_x shrt_pckt husb2dev interrupt disable dma channelx request
621 32054f?avr32?09/09 at32ap7002 31.6.10 power modes 31.6.10.1 controllin g device states a usb device has several possible states. refer to chapter 9 (usb device framework) of the universal serial bus specification, rev 2.0. figure 31-18. usbadevice state diagram movement from one state to another depends on the usb bus state or on standard requests sent through control transactions via the default endpoint (endpoint 0). after a period of bus inactivity, the us b device enters suspend mode. accepting sus- pend/resume requests from the usb host is mandatory. constraints in suspend mode are very strict for bus-powered applications; devices may not consume more than 500 a on the usb bus. while in suspend mode, the host may wake up a de vice by sending a resume signal (bus activ- ity) or a usb device may send a wake-up request to the host, e.g., waking up a pc by moving a usb mouse. attached suspended suspended suspended suspended hub reset or deconfigured hub configured bus inactive bus activity bus inactive bus activity bus inactive bus activity bus inactive bus activity reset reset address assigned device deconfigured device configured powered default address configured power interruption
622 32054f?avr32?09/09 at32ap7002 the wake-up feature is not mandatory for all devices and must be negotiated with the host. 31.6.10.2 from powered state to default state (reset) after its connection to a usb host, the usb device waits for an end-of-bus reset. the unmasked flag endreset is set in the ien regist er and an interr upt is triggered. once the endreset interrupt has be en triggered, the devi ce enters default st ate. in this state, the usba software must: ? enable the default endpoint, setting the ept_enabl flag in the eptctlenb[0] register and, optionally, enabling the interrupt for endpoint 0 by writing 1 in ept_int_0 of the ien register. the enumeration then begins by a control transfer. ? configure the interrupt mask register which has been reset by the usb reset detection ? enable the transceiver. in this state, the en_usba bit in ctrl register must be enabled. 31.6.10.3 from default state to address state (address assigned) after a set address standard device request, the usb host peripheral enters the address state. warning : before the device enters address state, it must achieve the status in transaction of the control transfer, i.e., the usba device sets it s new address once the tx_complt flag in the eptctl[0] register has been received and cleared. to move to address state, the driver software sets the dev_addr field and the faddr_en flag in the ctrl register. 31.6.10.4 from address state to configured state (device configured) once a valid set configuration standard request has been received and acknowledged, the device enables endpoints corresponding to the current configuration. this is done by setting the bk_number, ept_type, ept_dir and ept_size fi elds in the eptcfgx registers and enabling them by setting the ep t_enabl flag in the eptctlenbx registers, and, optionally, enabling corresponding interrupts in the ien register. 31.6.10.5 entering suspend state (bus activity) when a suspend (no bus activity on the usb bus ) is detected, the det_suspd signal in the intsta register is set. this triggers an interrupt if the corresponding bit is set in the ien register. this flag is cleared by writing to the clrint register. then the device enters suspend mode. in this state bus powered devices must drain less than 500 a from the 5v vbus. as an exam- ple, the microcontroller switches to slow clock, disables the pl l and main osc illator, and goes into idle mode. it may also switch off other devices on the board. the usbausba device peripheral clocks can be switched off. resume ev ent is asynchronously detected. 31.6.10.6 receiving a host resume in suspend mode, a resume event on the usb bus line is detected asynchronously, transceiver and clocks disabled (however the pull-up should not be removed).
623 32054f?avr32?09/09 at32ap7002 once the resume is detected on th e bus, the signal wake_up in the intsta is set. it may gen- erate an interrupt if the corresponding bit in the ien register is set. this interrupt may be used to wake-up the core , enable pll and main oscilla tors and configure clocks. 31.6.10.7 sending an external resume in suspend state it is possible to wake-up the host by sending an external resume. the device waits at least 5 ms after being entered in suspend state before sending an external resume. the device must force a k state from 1 to 15 ms to resume the host. 31.6.11 test mode a device must support the test_mode feature when in the default, address or configured high speed device states. test_mode can be: ?test_j ?test_k ? test_packet ? test_seo_nak (see section 31.7.11 ?usba test register? on page 640 for definitions of each test mode.) const char test_packet_buffer[] = { // jkjkjkjk * 9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // jjkkjjkk * 8 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, // jjkkjjkk * 8 0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee, // jjjjjjjkkkkkkk * 8 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // jjjjjjjk * 8 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd, // {jkkkkkkk * 10}, jk 0xfc,0x7e,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x7e };
624 32054f?avr32?09/09 at32ap7002 31.7 usb high speed device (usba) user interface table 31-6. register mapping offset register name access reset 0x00 usba control register ctrl read/write 0x0000_0200 0x04 usba frame number register fnum read 0x0000_0000 0x08 - 0x0c reserved ? ? ? 0x10 usba interrupt enable register ien read/write 0x0000_0010 0x14 usba interrupt status register intsta read 0x0000_0000 0x18 usba clear interrupt register clrint write ? 0x1c usba endpoints reset register eptrst write ? 0x20 - 0xcc reserved ? ? ? 0xd0 usba test sof counter register tstsofcnt read/write 0x0000_0000 0xd4 usba test a counter register tstcnta read/write 0x0000_0000 0xd8 usba test b counter register tstcntb read/write 0x0000_0000 0xdc usba test mode register tstmodereg read/write 0x0000_0000 0xe0 usba test register tst read/write 0x0000_0000 0xe4 - 0xe8 reserved ? ? ? 0xec usba paddrsize register ippaddrsize read 0x0000_4000 0xf0 usba name1 register ipname1 read 0x4855_5342 0xf4 usba name2 register ipname2 read 0x3244_4556 0xf8 usba features register ipfeatures read 0xfc usba ip version register ipversion read 0x100 usba endpoint configuration register eptcfgx read/write 0x0000_0000 0x104 usba endpoint control enable register eptctlenbx write ? 0x108 usba endpoint control disable register eptctldisx write ? 0x10c usba endpoint control register eptctlx read 0x0000_0000 (1) 0x110 reserved ? ? ? 0x114 usba endpoint set status register eptsetstax write ? 0x118 usba endpoint clear status register eptclrstax write ? 0x11c usba endpoint status register eptsta read 0x0000_0040 0x120 - 0x1fc endpoints 1 to 7 0x200 - 0x2fc endpoints 8 to 15 0x200 - 0x30c reserved ? ? ? 0x300 - 0x30c reserved ? ? ? 0x310 usba dma next descriptor address register dmanxtdscx read/write 0x0000_0000 0x314 usba dma channelx address register dmaaddressx read /write 0x0000_0000
625 32054f?avr32?09/09 at32ap7002 note: 1. the reset value for eptctl0 is 0x0000_0001 0x318 usba dma channelx control register dmacontrolx read/write 0x0000_0000 0x31c usba dma channelx status register dmastatusx read/write 0x0000_0000 0x320 - 0x37c dma channel 2 to 7 table 31-6. register mapping (continued) offset register name access reset
626 32054f?avr32?09/09 at32ap7002 31.7.1 usba control register name: ctrl access type: read/write ? dev_addr: usba address read: this field contains the default address (0) after power-up or usba bus reset. write: this field is written with the value set by a set_address request received by the device firmware. ? faddr_en: function address enable read: 0 = device is not in address state. 1 = device is in address state. write: 0 = only the default function address is used (0). 1 = this bit is set by the device firm ware after a successful status phase of a set_address transaction. when set, the only address accepted by the usba controller is the one stored in the usba ad dress field. it will not be cleared afterwards by the device firmware. it is cleared by hardware on hardware reset, or when usba bus reset is received (see above). ? en_usba: usba enable read: 0 = usba is disabled. 1 = usba is enabled. write: 0 = disable and reset the usba contro ller, disable the usba transceiver. 1 = enables the usba controller. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????rewakeupdetachen_usba 76543210 faddr_en dev_addr
627 32054f?avr32?09/09 at32ap7002 ? detach: detach command read: 0 = usba is attached. 1 = usba is detached, utmi transceiver is suspended. write: 0 = pull up the dp line (attach command). 1 = simulate a detach on the usba line and force the ut mi transceiver into suspe nd state (suspend m = 0). ? rewakeup : send remote wake up read: 0 = remote wake up is disabled. 1 = remote wake up is enabled. write: 0 = no effect. 1 = force an external interrupt on the usba controller for remote wake up purposes. an upstream resume is sent onl y after the usba bus has been in su spend state for at least 5 ms. this bit is automatically cleared by hardware at the end of the upstream resume.
628 32054f?avr32?09/09 at32ap7002 31.7.2 usba frame number register name: fnum access type: read ? micro_frame_num: microframe number number of the received microframe (0 to 7) in one frame.this field is reset at the beginning of each new frame (1 ms). one microframe is received each 125 microseconds (1 ms/8). ? frame_number: frame number as defined in the packet field formats this field is provided in the last received sof packet (see int_sof in the usba interrupt status register ). ? fnum_err: frame number crc error this bit is set by hardware when a corrupted frame number in start of frame packet (or micro sof) is received. this bit and the int_sof (or micro_sof) interrupt are updated at the same time. 31 30 29 28 27 26 25 24 fnum_err??????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ? ? frame_number 76543210 frame_number micro_frame_num
629 32054f?avr32?09/09 at32ap7002 31.7.3 usba interrupt enable register name: ien access type: read/write ? det_suspd: suspend interrupt enable read: 0 = suspend interrupt is disabled. 1 = suspend interrupt is enabled. write 0 = disable suspend interrupt. 1 = enable suspend interrupt. ? micro_sof: micro-sof interrupt enable read: 0 = micro-sof interrupt is disabled. 1 = micro-sof interrupt is enabled. write 0 = disable micro-sof interrupt. 1 = enable micro-sof interrupt. ? int_sof: sof interrupt enable read: 0 = sof interrupt is disabled. 1 = sof interrupt is enabled. write 0 = disable sof interrupt. 1 = enable sof interrupt. 31 30 29 28 27 26 25 24 dma_int_6 dma_int_5 dma_int_4 d ma_int_3 dma_int_2 dma_int_1 ? 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 ept_int_7 ept_int_6 ept_int_5 ept_int_4 ept_int_3 ept_int_2 ept_int_1 ept_int_0 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd ?
630 32054f?avr32?09/09 at32ap7002 ? endreset: end of reset interrupt enable read: 0 = end of reset interrupt is disabled. 1 = end of reset interrupt is enabled. write 0 = disable end of reset interrupt. 1 = enable end of reset interrupt. ? wake_up: wake up cpu interrupt enable read: 0 = wake up cpu interrupt is disabled. 1 = wake up cpu interrupt is enabled. write 0 = disable wake up cpu interrupt. 1 = enable wake up cpu interrupt. ? endofrsm: end of resume interrupt enable read: 0 = resume interrupt is disabled. 1 = resume interrupt is enabled. write 0 = disable resume interrupt. 1 = enable resume interrupt. ? upstr_res: upstream resume interrupt enable read: 0 = upstream resume interrupt is disabled. 1 = upstream resume interrupt is enabled. write 0 = disable upstream resume interrupt. 1 = enable upstream resume interrupt. ? ept_int_x: endpointx interrupt enable read: 0 = the interrupts for this endpoint are disabled. 1 = the interrupts for this endpoint are enabled. write 0 = disable the interrupts for this endpoint. 1 = enable the interrupts for this endpoint.
631 32054f?avr32?09/09 at32ap7002 ? dma_int_x: dma channelx interrupt enable read: 0 = the interrupts for this channel are disabled. 1 = the interrupts for this channel are enabled. write 0 = disable the interrupts for this channel. 1 = enable the interrupts for this channel.
632 32054f?avr32?09/09 at32ap7002 31.7.4 usba interrupt status register name: intsta access type: read-only ? speed: speed status 0 = reset by hardware when the hardware is in full speed mode. 1 = set by hardware when the hardware is in high speed mode ? det_suspd: suspend interrupt 0 = cleared by setting the det_suspd bit in clrint register 1 = set by hardware when a usba suspend (i dle bus for three frame periods, a j stat e for 3 ms) is detected. this triggers a usba interrupt w hen the det_suspd bit is set in ien register. ? micro_sof: micro start of frame interrupt 0 = cleared by setting the micro_sof bit in clrint register. 1 = set by hardware when an usba micro st art of frame pid (sof) has been detected (e very 125 us) or synthesized by the macro. this triggers a usba interrupt when the micro_sof bit is set in ie n. in case of de tected sof, the micro_frame_num field in fnum register is incremented and the frame_number field doesn?t change. note: the micro start of frame interrupt (micro_sof), and the star t of frame interrupt (int_sof) are not generated at the same time. ? int_sof: start of frame interrupt 0 = cleared by setting the int_sof bit in clrint. 1 = set by hardware when an usba start of frame pid (sof) has been detected (every 1 ms) or synthesized by the macro. this triggers a usba interrupt when the int_sof bit is set in ien register. in case of detected sof, in high speed mode, the micro_frame_number field is cleared in fn um register and the frame_number field is updated. ? endreset: end of reset interrupt 0 = cleared by setting th e endreset bit in clrint. 1 = set by hardware when an end of rese t has been detected by the usba controller. this trig gers a usba interrupt when the endreset bit is set in ien. 31 30 29 28 27 26 25 24 dma_int_6 dma_int_5 dma_int_4 dma_int_3 dma_int_2 dma_int_1 ? 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 ept_int_7 ept_int_6 ept_int _5 ept_int_4 ept_int_3 ept_i nt_2 ept_int_1 ept_int_0 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd speed
633 32054f?avr32?09/09 at32ap7002 ? wake_up: wake up cpu interrupt 0 = cleared by setting the wake_up bit in clrint. 1 = set by hardware when the usba controller is in suspen d state and is re-activated by a filtered non-idle signal from the usba line (not by an upstre am resume). this trig gers a usba interrupt when the wake_ up bit is set in ien register. when receiving this interrupt, the user has to enable the device controller clock prior to operation. note: this interrupt is generated even if the device controller clock is disabled. ? endofrsm: end of resume interrupt 0 = cleared by setting the endofrsm bit in clrint. 1 = set by hardware when the usba controller detects a good end of resume signal initiated by the host. this triggers a usba interrupt when the endofrsm bit is set in ien. ? upstr_res: upstream resume interrupt 0 = cleared by setting the upstr_res bit in clrint. 1 = set by hardware when the usba contro ller is sending a resume signal called ? upstream resume?. th is triggers a usba interrupt when the upstr_res bit is set in ien. ? ept_int_x: endpointx interrupt 0 = reset when the eptstax interrupt source is cleared. 1 = set by hardware when an interrupt is triggered by the eptst ax register and this endpoint interrupt is enabled by the ept_int_x bit in ien. ? dma_int_x: dma channelx interrupt 0 = reset when the dmastatusx interrupt source is cleared. 1 = set by hardware when an interrupt is triggered by the dma channelx and this endpoint interrupt is enabled by the dma_int_x bit in ien.
634 32054f?avr32?09/09 at32ap7002 31.7.5 usba clear interrupt register name: clrint access type: write only ? det_suspd: suspend interrupt clear 0 = no effect. 1 = clear the det_suspd bit in intsta. ? micro_sof: micro start of frame interrupt clear 0 = no effect. 1 = clear the micro_sof bit in intsta. ? int_sof: start of frame interrupt clear 0 = no effect. 1 = clear the int_sof bit in intsta. ? endreset: end of re set interrupt clear 0 = no effect. 1 = clear the endreset bit in intsta. ? wake_up: wake up cpu interrupt clear 0 = no effect. 1 = clear the wake_up bit in intsta. ? endofrsm: end of resume interrupt clear 0 = no effect. 1 = clear the endofrsm bit in intsta. ? upstr_res: upstream resume interrupt clear 0 = no effect. 1 = clear the upstr_res bit in intsta. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd ?
635 32054f?avr32?09/09 at32ap7002 31.7.6 usba endpoints reset register name: eptrst access type: write only ? rst_ept_x: endpointx reset 0 = no effect. 1 = reset the endpointx state. setting this bit clears the endpoint status eptst ax register, except for the togglesq_sta field. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 76543210 rst_ept_7 rst_ept_6 rst_ept _5 rst_ept_4 rst_ept_3 rst_ ept_2 rst_ept_1 rst_ept_0
636 32054f?avr32?09/09 at32ap7002 31.7.7 usba test sof counter register name: tstsofcnt access type: read/write ? sofcntmax: sof counter max value ? sofctload: sof counter load 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 sofctload sofcntmax
637 32054f?avr32?09/09 at32ap7002 31.7.8 usba test a counter register name: tstcnta access type: read/write ? cntaload: a counter load ? cntamax: a counter max value 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cntaload cntamax 76543210 cntamax
638 32054f?avr32?09/09 at32ap7002 31.7.9 usba test b counter register name: tstcntb access type: read/write ? cntbload: b counter load ? cntbmax: b counter max value 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 cntbload ? cntbmax
639 32054f?avr32?09/09 at32ap7002 31.7.10 usba test mode register name: tstmodereg access type: read/write ? tstmode: usba core testmodereg 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?? tstmode
640 32054f?avr32?09/09 at32ap7002 31.7.11 usba test register name: tst access type: read/write ? speed_cfg: speed configuration read/write: speed configuration: ? tst_j: test j mode read and write: 0 = no effect. 1 = set to send the j state on the usba line. this enables the testing of the high output drive level on the d+ line. ? tst_k: test k mode read and write: 0 = no effect. 1 = set to send the k state on the usba line. this enables the test ing of the high output dr ive level on the d- line. ? tst_pkt: test packet mode read and write: 0 = no effect. 1 = set to repetitively transmit the packet stored in the current bank. this enables the testing of rise and fall times, eye pa t- terns, jitter, and any other dynamic waveform specifications. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? opmode2 tst_pkt tst_k tst_j speed_cfg 00 normal mode: the macro is in full speed mode, ready to make a high speed identification, if the host supports it and then to automatically switch to high speed mode 01 reserved 10 force high speed: set this value to force the hardware to work in high speed mode. only for debug or test purpose. 11 force full speed: set this value to force the hardware to work only in full speed mode. in this configuration, the macro will not respond to a high speed reset handshake
641 32054f?avr32?09/09 at32ap7002 ? opmode2: opmode2 read and write: 0 = no effect. 1 = set to force the opmode signal (utmi interface) to ?10?, to disable the bit-stuffing and the nrzi encoding. note: for the test mode, test_se0_nak (see universal serial bus specification, revision 2.0: 7.1.20, test mode sup- port). force the device in high speed m ode, and configure a bulk-ty pe endpoint. do not fill this endpoint for sending nak to the host. upon command, a port?s transceiver must enter the high speed receive mode and remain in that mode until the exit action is taken. this enables the testing of output impedance, low level output voltage and loading characteristics. in addition, while in this mode, upstream facing ports (and only upstream facing ports) must respond to any in token packet with a nak handshake (only if the packet crc is dete rmined to be correct) within the norm al allowed device response time. this enables testing of the device squelch level circuitry and, additi onally, provides a general purpose stimulus/response test for basic functional testing.
642 32054f?avr32?09/09 at32ap7002 31.7.12 usba paddrsize register name: ippaddrsize access type: read-only ? ip_paddrsize 2^paddr_size pb address bus aperture of the usba 31 30 29 28 27 26 25 24 ip_paddrsize 23 22 21 20 19 18 17 16 ip_paddrsize 15 14 13 12 11 10 9 8 ip_paddrsize 76543210 ip_paddrsize
643 32054f?avr32?09/09 at32ap7002 31.7.13 usba na me1 register name: ipname1 access type: read-only ? ip_name1 ascii string ?husb? 31 30 29 28 27 26 25 24 ip_name1 23 22 21 20 19 18 17 16 ip_name1 15 14 13 12 11 10 9 8 ip_name1 76543210 ip_name1
644 32054f?avr32?09/09 at32ap7002 31.7.14 usba na me2 register name: ipname2 access type: read-only ? ip_name2 ascii string ?2dev? 31 30 29 28 27 26 25 24 ip_name2 23 22 21 20 19 18 17 16 ip_name2 15 14 13 12 11 10 9 8 ip_name2 76543210 ip_name2
645 32054f?avr32?09/09 at32ap7002 31.7.15 usba features register name: ipfeatures access type: read-only ? ept_nbr_max: max number of endpoints give the max number of endpoints. 0 = if 16 endpoints are hardware implemented. 1 = if 1 endpoint is hardware implemented. 2 = if 2 endpoints are hardware implemented. ... 15 = if 15 endpoints are hardware implemented. ? dma_channel_nbr: number of dma channels give the number of dma channels. 1 = if 1 dma channel is hardware implemented. 2 = if 2 dma channels are hardware implemented. ... 7 = if 7 dma channels are hardware implemented. ? dma_b_siz: dma buffer size 0 = if the dma buffer size is 16 bits. 1 = if the dma buffer size is 24 bits. ? dma_fifo_word_depth: dma fifo depth in words 0 = if fifo is 16 words deep. 1 = if fifo is 1 word deep. 2 = if fifo is 2 words deep. ... 15 = if fifo is 15 words deep. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 iso_ept_7 iso_ept_6 iso_ept_5 iso_ept_4 is o_ept_3 iso_ept_2 iso_ept_1 datab16_8 15 14 13 12 11 10 9 8 bw_dpram fifo_max_size dma_fifo_word_depth 76543210 dma_b_siz dma_channel_nbr ept_nbr_max
646 32054f?avr32?09/09 at32ap7002 ? fifo_max_size: dpram size 0 = if dpram is 128 bytes deep. 1 = if dpram is 256 bytes deep. 2 = if dpram is 512 bytes deep. 3 = if dpram is 1024 bytes deep. 4 = if dpram is 2048 bytes deep. 5 = if dpram is 4096 bytes deep. 6 = if dpram is 8192 bytes deep. 7 = if dpram is 16384 bytes deep. ? bw_dpram: dpram by te write capability 0 = if dpram write data shadow logic is implemented. 1 = if dpram is byte write capable. ? datab16_8: utmi databus16_8 0 = if the utmi uses an 8-bit parallel data interface (60 mhz, unidirectional). 1 = if the utmi uses a 16-bit parallel data interface (30 mhz, bidirectional). ? iso_ept_x: endpointx high bandwidth isochronous capability 0 = if the endpoint does not have isochronous high bandwidth capability. 1 = if the endpoint has isochronous high bandwidth capability.
647 32054f?avr32?09/09 at32ap7002 31.7.16 usba ip version register name: ipversion access type: read-only ? version_num: ip version give the ip version. ? metal_fix_num: number of metal fixes give the number of metal fixes. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? metal_fix_num 15 14 13 12 11 10 9 8 version_num 76543210 version_num
648 32054f?avr32?09/09 at32ap7002 31.7.17 usba endpoint configuration register name: eptcfgx access type: read/write ? ept_size: endpoint size read and write: set this field according to the endpoint size in bytes (see section 31.6.4 ?endpoint configuration? ). endpoint size note: 1. 1024 bytes is only for isochronous endpoint. ? ept_dir: endpoint direction read and write: 0 = clear this bit to configure out direction for bulk, interrupt and isochronous endpoints. 1 = set this bit to configure in direction for bulk, interrupt and isochronous endpoints. for control endpoints this bit has no effect and should be left at zero. ? ept_type: endpoint type read and write: set this field according to the endpoint type (see section 31.6.4 ?endpoint configuration? ). (endpoint 0 should always be configured as control) 31 30 29 28 27 26 25 24 ept_mapd??????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????? nb_trans 76543210 bk_number ept_type ept_dir ept_size 000 8 bytes 001 16 bytes 010 32 bytes 011 64 bytes 100 128 bytes 101 256 bytes 110 512 bytes 111 1024 bytes (1)
649 32054f?avr32?09/09 at32ap7002 endpoint type: ? bk_number: number of banks read and write: set this field according to the endpoint?s number of banks (see section 31.6.4 ?endpoint configuration? ). number of banks ? nb_trans: number of tr ansaction per microframe read and write: the number of transactions per microframe is set by software. note: meaningful for high bandwidth isochronous endpoint only. ? ept_mapd: endpoint mapped read-only: 0 = the user should reprogram the register with correct values. 1 = set by hardware when the endpoint size (ept_size) an d the number of banks (bk_number) are correct regarding: ? the fifo max capacity (fifo_max_size in ipfeatures register) ? the number of endpoints/banks already allocated ? the number of allowed banks for this endpoint 00 control endpoint 01 isochronous endpoint 10 bulk endpoint 11 interrupt endpoint 00 zero bank, the endpoint is not mapped in memory 01 one bank (bank 0) 10 double bank (ping-pong: bank 0/bank 1) 11 triple bank (bank 0/bank 1/bank 2)
650 32054f?avr32?09/09 at32ap7002 31.7.18 usba endpoint control enable register name: eptctlenbx access type: write-only for additional information, see ?usba endpoint control register? on page 654 . ? ept_enabl: endpoint enable 0 = no effect. 1 = enable endpoint according to the device configuration. ? auto_valid: packet auto-valid enable 0 = no effect. 1 = enable this bit to automatically validate the current packet and switch to the next bank for both in and out transfers. ? intdis_dma: interrupts disable dma 0 = no effect. 1 = if set, when an enabled endpoint-originated interrupt is triggered, the dma request is disabled. ? nyet_dis: nyet disable (only fo r high speed bulk out endpoints) 0 = no effect. 1 = forces an ack response to the next high spee d bulk out transfer instead of a nyet response. ? datax_rx: datax interrupt enable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = enable datax interrupt. ? mdata_rx: mdata interrupt enable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = enable mdata interrupt. 31 30 29 28 27 26 25 24 shrt_pckt??????? 23 22 21 20 19 18 17 16 ?????busy_bank?? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx ? nyet_dis intdis_dma ? auto_valid ept_enabl
651 32054f?avr32?09/09 at32ap7002 ? err_ovflw: overflow error interrupt enable 0 = no effect. 1 = enable overflow error interrupt. ? rx_bk_rdy: received out data interrupt enable 0 = no effect. 1 = enable received out data interrupt. ? tx_complt: transmitted in data complete interrupt enable 0 = no effect. 1 = enable transmitted in data complete interrupt. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt enable 0 = no effect. 1 = enable tx packet ready/transaction error interrupt. ? rx_setup/err_fl_iso: received set up/error flow interrupt enable 0 = no effect. 1 = enable rx_setup/error flow iso interrupt. ? stall_snt/err_criso/err_nbtra: stal l sent /iso crc error/number of transaction error interrupt enable 0 = no effect. 1 = enable stall sent/error crc iso/erro r number of tran saction interrupt. ? nak_in/err_flush: nakin/bank flush error interrupt enable 0 = no effect. 1 = enable nakin/bank flush error interrupt. ? nak_out: nakout interrupt enable 0 = no effect. 1 = enable nakout interrupt. ? busy_bank: busy bank interrupt enable 0 = no effect. 1 = enable busy bank interrupt. ? shrt_pckt: short packet send/short packet interrupt enable for out endpoints: 0 = no effect. 1 = enable short packet interrupt. for in endpoints: guarantees short packet at end of dma transfer if the dmacontrolx register end_b_en and eptctlx register autovalid bits are also set.
652 32054f?avr32?09/09 at32ap7002 31.7.19 usba endpoint control disable register name: eptctldisx access type: write-only for additional information, see ?usba endpoint control register? on page 654 . ? ept_disabl: endpoint disable 0 = no effect. 1 = disable endpoint. ? auto_valid: packet auto-valid disable 0 = no effect. 1 = disable this bit to not automatically validate the current packet. ? intdis_dma: interrupts disable dma 0 = no effect. 1 = disable the ?interrupts disable dma?. ? nyet_dis: nyet enable (only for high speed bulk out endpoints) 0 = no effect. 1 = let the hardware handle the handshake response for the high speed bulk out transfer. ? datax_rx: datax interrupt disable (only fo r high bandwidth isochronous out endpoints) 0 = no effect. 1 = disable datax interrupt. ? mdata_rx: mdata interrupt disable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = disable mdata interrupt. 31 30 29 28 27 26 25 24 shrt_pckt??????? 23 22 21 20 19 18 17 16 ?????busy_bank?? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx ? nyet_dis intdis_dma ? auto_valid ept_disabl
653 32054f?avr32?09/09 at32ap7002 ? err_ovflw: overflow error interrupt disable 0 = no effect. 1 = disable overflow error interrupt. ? rx_bk_rdy: received out data interrupt disable 0 = no effect. 1 = disable received out data interrupt. ? tx_complt: transmitted in data complete interrupt disable 0 = no effect. 1 = disable transmitted in data complete interrupt. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt disable 0 = no effect. 1 = disable tx packet ready/transaction error interrupt. ? rx_setup/err_fl_iso: received setup /error flow interrupt disable 0 = no effect. 1 = disable rx_setup/error flow iso interrupt. ? stall_snt/err_criso/err_nbtra: stall sent/iso crc er ror/number of transacti on error interrupt disable 0 = no effect. 1 = disable stall sent/error crc iso/error number of transaction interrupt. ? nak_in/err_flush: nakin/bank flush error interrupt disable 0 = no effect. 1 = disable nakin/ bank flush error interrupt. ? nak_out: nakout interrupt disable 0 = no effect. 1 = disable nakout interrupt. ? busy_bank: busy bank interrupt disable 0 = no effect. 1 = disable busy bank interrupt. ? shrt_pckt: short packet interrupt disable for out endpoints: 0 = no effect. 1 = disable short packet interrupt. for in endpoints: never automatically add a zero length packet at end of dma transfer. .
654 32054f?avr32?09/09 at32ap7002 31.7.20 usba endpoint control register name: eptctlx access type: read-only ? ept_enabl: endpoint enable 0 = if cleared, the endpoint is disabled according to the devi ce configuration. endpoint 0 should always be enabled after a hardware or usba bus reset and participate in the device configuration. 1 = if set, the endpoint is enabled according to the device configuration. ? auto_valid: packet auto-valid enabled (not for control endpoints) set this bit to automatically validate the current packet and switch to the next bank for both in and out endpoints. for in transfer: if this bit is set, then the eptstax register tx_pk_rdy bit is set automatically when the current bank is full and at the end of dma buffer if the dmacontrolx register end_b_en bit is set. the user may still set the eptstax register tx_pk_rdy bit if the current bank is not full, unless the user wants to send a zero length packet by software. for out transfer: if this bit is set, then the eptstax register rx_bk_rdy bit is automatically reset for the current bank when the last packet byte has been read from the bank fifo or at the end of dma buffer if the dm acontrolx regi ster end_b_en bit is set. for example, to truncate a padded data pack et when the actual data transfer size is reached. the user may still clear the eptstax regi ster rx_bk_rdy bit, for ex ample, after comp leting a dma buffer by software if dmacontrolx register end_b_en bit was disabled or in order to cancel the read of the remaining data bank(s). ? intdis_dma: interrupt disables dma if set, when an enabled endpoint-originated interrupt is tri ggered, the dma request is disabled regardless of the ien regis- ter ept_int_x bit for this endpoint. then, the firmware will have to clear or disable the interrupt source or clear this bit if transfer completion is needed. if the exception raised is associated with the new system bank packet, then the previous dma packet transfer is normally completed, but the new dma packet transfer is not started (not requested). if the exception raised is not associated to a new system bank packet (nak_in, nak_out, err_fl_iso...), then the request cancellation may happen at any time and may immediately stop the current dma transfer. 31 30 29 28 27 26 25 24 shrt_pckt??????? 23 22 21 20 19 18 17 16 ?????busy_bank?? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx ? nyet_dis intdis_dma ? auto_valid ept_enabl
655 32054f?avr32?09/09 at32ap7002 this may be used, for example, to identify or prevent an erroneous packet to be transferred into a buffer or to complete a dma buffer by software after reception of a short packet, or to perform buffer truncation on err_fl_iso interrupt for adaptive rate. ? nyet_dis: nyet disable (only for high speed bulk out endpoints) 0 = if clear, this bit lets the hardware handle the handshake response for the high speed bulk out transfer. 1 = if set, this bit forces an ack response to the next high speed bulk out transfer instead of a nyet response. note: according to the universal serial bus specification, rev 2.0 (8.5.1.1 nak responses to out/ data during ping protocol), a nak response to an hs bulk out transfer is expected to be an unusual occurrence. ? datax_rx: datax interrupt enabled (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = send an interrupt when a data2, da ta1 or data0 packet has been received meaning the whole microframe data payload has been received. ? mdata_rx: mdata interrupt enabled (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = send an interrupt when an mdata packet has been received and so at least one packet of the microframe data pay- load has been received. ? err_ovflw: overflow error interrupt enabled 0 = overflow error interrupt is masked. 1 = overflow error interrupt is enabled. ? rx_bk_rdy: received out data interrupt enabled 0 = received out data interrupt is masked. 1 = received out data interrupt is enabled. ? tx_complt: transmitted in data complete interrupt enabled 0 = transmitted in data co mplete interrupt is masked. 1 = transmitted in data comp lete interrupt is enabled. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt enabled 0 = tx packet ready/transaction error interrupt is masked. 1 = tx packet ready/transaction error interrupt is enabled. caution: interrupt source is active as long as the correspondi ng eptstax register tx_pk_rdy flag remains low. if there are no more banks available for transmitting after the software has set eptstax/tx_pk_rdy for the last trans- mit packet, then the interrupt source remains inacti ve until the first bank becomes free again to transmit at eptstax/tx_pk_rdy hardware clear. ? rx_setup/err_fl_iso: received setup /error flow interrupt enabled 0 = received setup/error flow interrupt is masked. 1 = received setup/error flow interrupt is enabled.
656 32054f?avr32?09/09 at32ap7002 ? stall_snt/err_criso/err_nbtra: stall sent/iso crc er ror/number of transaction error interrupt enabled 0 = stall sent/iso crc error/number of transaction error interrupt is masked. 1 = stall sent /iso crc error/number of transaction error interrupt is enabled. ? nak_in/err_flush: nakin/bank flush error interrupt enabled 0 = nakin interrupt is masked. 1 = nakin/bank flush error interrupt is enabled. ? nak_out: nakout interrupt enabled 0 = nakout interrupt is masked. 1 = nakout interrupt is enabled. ? busy_bank: busy bank interrupt enabled 0 = busy_bank interrupt is masked. 1 = busy_bank interrupt is enabled. for out endpoints : an interrupt is sent when all banks are busy. for in endpoints: an interrupt is sent when all banks are free . ? shrt_pckt: short packet interrupt enabled for out endpoints : send an interrupt when a short packet has been received. 0 = short packet interrupt is masked. 1 = short packet interrupt is enabled. for in endpoints : a short packet transmission is guaranteed upon end of the dma transfer, thus signaling a bulk or interrupt end of transfer or an end of isochronous (m icro-)frame data, but only if the dmacontrolx register end_b_en and eptctlx register auto_valid bits are also set.
657 32054f?avr32?09/09 at32ap7002 31.7.21 usba endpoint set status register name: eptsetstax access type: write-only ? frcestall: stall handshake request set 0 = no effect. 1 = set this bit to request a stall answer to the host for the next handshake refer to chapters 8.4.5 (handshake packets) and 9.4.5 (get status) of the universal serial bus sp ecification, rev 2.0 for more information on the stall handshake. ? kill_bank: kill bank set (for in endpoint) 0 = no effect. 1 = kill the last written bank. ? tx_pk_rdy: tx packet ready set 0 = no effect. 1 = set this bit after a packet has been written into the endpoint fifo for in data transfers ? this flag is used to generate a data in transaction (device to host). ? device firmware checks that it can write a data payload in the fifo, checking that tx_pk_rdy is cleared. ? transfer to the fifo is done by writing in the ?buffer address? register. ? once the data payload has been transferred to the fifo, the firmware notifi es the usba device setting tx_pk_rdy to one. ? usba bus transactions can start. ? txcomp is set once the data payload has been received by the host. ? data should be written into the endpoint fifo only after this bit has been cleared. ? set this bit without writing data to the endpoint fifo to send a zero length packet. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????tx_pk_rdy?ki ll_bank ? 76543210 ??frcestall?????
658 32054f?avr32?09/09 at32ap7002 31.7.22 usba endpoint clear status register name: eptclrstax access type: write-only ? frcestall: stall handshake request clear 0 = no effect. 1 = clear the stall request. the next packets from host will not be stalled. ? togglesq: data toggle clear 0 = no effect. 1 = clear the pid data of the current bank for out endpoints, the next received packet should be a data0. for in endpoints, the next pa cket will be sent with a data0 pid. ? rx_bk_rdy: receive d out data clear 0 = no effect. 1 = clear the rx_bk_rdy flag of eptstax. ? tx_complt: transmitted in data complete clear 0 = no effect. 1 = clear the tx_complt flag of eptstax. ? rx_setup/err_fl_iso: received setup/error flow clear 0 = no effect. 1 = clear the rx_setup/err_fl_iso flags of eptstax. ? stall_snt/err_nbtra: stall sent/number of transaction error clear 0 = no effect. 1 = clear the stall_snt/err_nbtra flags of eptstax. ? nak_in/err_flush: nakin/bank flush error clear 0 = no effect. 1 = clear the nak_in/err_flush flags of eptstax. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_nbtra rx_setup/ err_fl_iso ? tx_complt rx_bk_rdy ? 76543210 ?togglesqfrcestall?????
659 32054f?avr32?09/09 at32ap7002 ? nak_out: nakout clear 0 = no effect. 1 = clear the nak_out flag of eptstax.
660 32054f?avr32?09/09 at32ap7002 31.7.23 usba endpoint status register name: eptstax access type: read-only ? frcestall: stall handshake request 0 = no effect. 1= if set a stall answer will be done to the host for the next handshake. this bit is reset by hardware upon received setup. ? togglesq_sta: toggle sequencing toggle sequencing: in endpoint : it indicates the pid data toggle that will be used for the next packet sent. this is not relative to the current bank. control and out endpoint : these bits are set by hardware to indicate the pid data of the current bank: note 1: in out transfer, the toggle information is meaningful only when the current bank is busy (received out data = 1). note 2: these bits are updated for out transfer: ? a new data has been written into the current bank. ? the user has just cleared the received out data bit to switch to the next bank. note 3: for high bandwidth isochronous out endpoint, it is recommended to check the eptstax/err_trans bit to know if the toggle sequencing is correct or not. note 4: this field is reset to data1 by the eptclrstax register togglesq bit, and by eptctldisx (disable endpoint). 31 30 29 28 27 26 25 24 shrt_pckt byte_count 23 22 21 20 19 18 17 16 byte_count busy_bank_sta current_bank/ control_dir 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy/ kill_bank err_ovflw 76543210 togglesq_stafrcestall????? 00 data0 01 data1 10 data2 (only for high bandwidth isochronous endpoint) 11 mdata (only for high bandwidth isochronous endpoint)
661 32054f?avr32?09/09 at32ap7002 ? err_ovflw: overflow error this bit is set by hardware when a new too-long packet is received. example: if the user programs an endpoint 64 bytes wide and th e host sends 128 bytes in an out transfer, then the over- flow error bit is set. this bit is updated at the same time as the byte_count field. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). ? rx_bk_rdy/kill_bank: rece ived out data/kill bank received out data : (for out endpoint or control endpoint) this bit is set by hardware after a new packet has been stored in the endpoint fifo. this bit is cleared by the device firmware af ter reading the out data from the endpoint. for multi-bank endpoints, this bit may remain active even when cleared by the device firmware, this if an other packet has been received meanwhile. hardware assertion of this bit may generate an interrupt if enabled by the eptctlx register rx_bk_rdy bit. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). kill bank : (for in endpoint) ? the bank is really cleared or the bank is sent, busy_bank_sta is decremented. ? the bank is not cleared but sent on the in transfer, tx_complt ? the bank is not cleared because it was empty. the user sh ould wait that this bit is cleared before trying to clear another packet. note: ?kill a packet? may be refused if at t he same time, an in token is coming and the current packet is sent on the usba line. in this case, the tx_complt bit is set. take notice however, that if at least two banks are ready to be sent, there is no problem to kill a packet even if an in token is coming. in fa ct, in that case, the current bank is sent (in transfer) and th e last bank is killed. ? tx_complt: transmitted in data complete this bit is set by hardware after an in packet has been transmitted for isochronous endpoints and after it has been accepted (ack?ed) by the host for control, bulk and interrupt endpoints. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). ? tx_pk_rdy/err_trans: tx packet ready/transaction error tx packet ready: this bit is cleared by hardware, as soon as the packet has been sent for isochronous endpoints, or after the host has acknowledged the packet for control, bulk and interrupt endpoints. for multi-bank endpoints, this bit may remain clear even afte r software is set if another bank is available to transmit. hardware clear of this bit may generate an interrupt if enabled by the eptctlx register tx_pk_rdy bit. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). transaction error : (for high bandwidth isochronous out endpoints) (read-only) this bit is set by hardware when a transa ction error occurs inside one microframe. if one toggle sequencing problem occurs amo ng the n-transactions (n = 1, 2 or 3) in side a microframe, then this bit is still set as long as the current bank contains one ?bad? n-transaction. (see ?current_bank/control_dir: current
662 32054f?avr32?09/09 at32ap7002 bank/control direction? on page 663 ) as soon as the current bank is relative to a new ?good? n-transactions, then this bit is reset. note1 : a transaction error occurs when the toggle sequencing does not respect the universal serial bus specification, rev 2.0 (5.9.2 high bandwidth isochronous endpoints) (bad pid, missing data....) note2 : when a transaction error occurs, the user may empty all the ?bad? transactions by clearing the received out data flag (rx_bk_rdy). if this bit is reset, then the user should consider that a new n-transaction is coming. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). ? rx_setup/err_fl_iso: received setup/error flow received setup : (for control endpoint only) this bit is set by hardware when a valid setup packet has been received from the host. it is cleared by the device firmware after reading the setup data from the endpoint fifo. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). error flow : (for isochronous endpoint only) this bit is set by hardware w hen a transaction error occurs. ? isochronous in transaction is missed, the micr o has no time to fill t he endpoint (underflow). ? isochronous out data is dropped because the bank is busy (overflow). this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). ? stall_snt/err_criso/err_nbtra: stall sent/c rc iso error/number of transaction error stall_snt : (for control, bulk and interrupt endpoints) this bit is set by hardware after a stall handshake has bee n sent as requested by the eptstax register frcestall bit. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). err_criso : (for isochronous out endpoints) (read-only) this bit is set by hardware if the last received data is corrupted (crc error on data). this bit is updated by hardware when new data is received (received out data bit). err_nbtra : (for high bandwidth isochronous in endpoints) this bit is set at the end of a microframe in which at l east one data bank has been transmitted, if less than the number of transactions per micro-frame banks (eptcfgx register nb _trans) have been validated for transmission inside this microframe. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). ? nak_in/err_flush: nak in/bank flush error nak_in : this bit is set by hardware when a nak handshake has bee n sent in response to an in request from the host. this bit is cleared by software. err_flush : (for high bandwidth isochronous in endpoints) this bit is set when flushing unsent banks at the end of a microframe.
663 32054f?avr32?09/09 at32ap7002 this bit is reset by eptrst register rst_ept_x (reset endpoint) and by ept_ctl_disx (disable endpoint). ? nak_out: nak out this bit is set by hardware when a nak handshake has been sent in response to an out or ping request from the host. this bit is reset by eptrst register rst_ept_x (reset endpoint) and by ept_ctl_disx (disable endpoint). ? current_bank/control_dir: cu rrent bank/control direction current bank : (all endpoints except control endpoint) these bits are set by hardware to indicate the number of the current bank. note: the current bank is updated each time the user: ? sets the tx packet ready bit to prepare the next in transfer and to switch to the next bank. ? clears the received out data bit to access the next bank. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). control direction : (for control endpoint only) 0 = a control write is requested by the host. 1 = a control read is requested by the host. note1: this bit corresponds with the 7th bit of the bmrequesttype (byte 0 of the setup data). note2: this bit is updated after receiving new setup data. ? busy_bank_sta: busy bank number these bits are set by hardware to indicate the number of busy banks. in endpoint : it indicates the number of busy banks filled by the us er, ready for in transfer. out endpoint : it indicates the number of busy banks filled by out transaction from the host. ? byte_count: usba byte count byte count of a received data packet. this field is incremented after each write into the endpoint (to prepare an in transfer). this field is decremented after each reading into the endpoint (out transfer). this field is also updated at rx_bk_rdy flag clear with the next bank. this field is also updated at tx_pk_rdy flag set with the next bank. 00 bank 0 (or single bank) 01 bank 1 10 bank 2 11 invalid 00 all banks are free 01 1 busy bank 10 2 busy banks 11 3 busy banks
664 32054f?avr32?09/09 at32ap7002 this field is reset by rst_ept_x of eptrst register. ? shrt_pckt: short packet an out short packet is detected when the receive byte count is less than the configured eptcfgx register ept_size. this bit is updated at the same time as the byte_count field. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint).
665 32054f?avr32?09/09 at32ap7002 31.7.24 usba dma channel transfer descriptor the dma channel transfer descriptor is loaded from the memory. be careful with the alignment of this buffer. the structure of the dma channel transfer descriptor is defined by three parameters as described below: offset 0: the address must be aligned: 0xxxxx0 next descriptor address register: dmanxtdscx offset 4: the address must be aligned: 0xxxxx4 dma channelx address register: dmaaddressx offset 8: the address must be aligned: 0xxxxx8 dma channelx control register: dmacontrolx to use the dma channel transfer descriptor, fill the structures with the correct va lue (as described in the following pages). then write directly in dmanxtdscx the address of the descriptor to be used first. then write 1 in the ldnxt_dsc bit of dmacontrolx (load next channel transfer descriptor). the descriptor is automat- ically loaded upon endpointx request for packet transfer.
666 32054f?avr32?09/09 at32ap7002 31.7.25 usba dma next descriptor address register name: dmanxtdscx access type: read/write ? nxt_dsc_add this field points to the next channel descri ptor to be processed. this channel descri ptor must be aligned, so bits 0 to 3 of the address must be equal to zero. 31 30 29 28 27 26 25 24 nxt_dsc_add 23 22 21 20 19 18 17 16 nxt_dsc_add 15 14 13 12 11 10 9 8 nxt_dsc_add 76543210 nxt_dsc_add
667 32054f?avr32?09/09 at32ap7002 31.7.26 usba dma channelx address register name: dmaaddressx access type: read/write ? buff_add this field determines the hsb bus starting address of a dma channel transfer. channel start and end addresses may be aligned on any byte boundary. the firmware may write this field only when th e dmastatus register chann_enb bit is clear. this field is updated at the end of the address phase of the current access to the hsb bus. it is incrementing of the access byte width. the access width is 4 bytes (or less) at packet start or end, if the start or end address is not aligned on a word boundary. the packet start address is either the channel start addres s or the next channel address to be accessed in the channel buffer. the packet end address is either the channel end address or the latest channel address accessed in the channel buffer. the channel start address is written by software or loaded fr om the descriptor, whereas the channel end address is either determined by the end of buffer or th e usba device, usb end of tr ansfer if the dmacontrolx register end_tr_en bit is set. 31 30 29 28 27 26 25 24 buff_add 23 22 21 20 19 18 17 16 buff_add 15 14 13 12 11 10 9 8 buff_add 76543210 buff_add
668 32054f?avr32?09/09 at32ap7002 31.7.27 usba dma channelx control register name: dmacontrolx access type: read/write ? chann_enb (channel enable command) 0 = dma channel is disabled at and no transfer will occur upon request. this bit is also cl eared by hardware when the chan- nel source bus is disabled at end of buffer. if the dmacontrol register ldnxt_ds c bit has been cleared by descriptor lo ading, the firmware will have to set the corresponding chann_enb bit to start the described transfer, if needed. if the dmacontrol register ldnxt_dsc bit is cleared, t he channel is frozen and the channel registers may then be read and/or written reliably as soon as both dmasta tus register chann_enb and chann_act flags read as 0. if a channel request is currently serviced when this bit is clear ed, the dma fifo buffer is drained until it is empty, then the dmastatus register chann_enb bit is cleared. if the ldnxt_dsc bit is set at or after this bit clearing, then the currently loaded descriptor is skipped (no data transfer occurs) and the next descriptor is immediately loaded. 1 = dmastatus register chann_enb bit will be set, thus enabling dma channel data transfer. then any pending request will start the transfer. th is may be used to start or resume any requested transfer. ? ldnxt_dsc: load next channel transfer descriptor enable (command) 0 = no channel register is loaded after the end of the channel transfer. 1 = the channel controller loads the next descriptor after the end of the current transfer, i.e. when the dmasta- tus/chann_enb bit is reset. if the dma control/chann_enb bi t is cleared, the next descriptor is im mediately loaded upon transfer request. dma channel control command summary ? end_tr_en: end of transfer enable (control) 31 30 29 28 27 26 25 24 buff_length 23 22 21 20 19 18 17 16 buff_length 15 14 13 12 11 10 9 8 ???????? 76543210 burst_lck desc_ld_it end_buffit end_tr_it end_b_en end_tr_en ldnxt_dsc chann_enb ldnxt_dsc chann_enb description 0 0 stop now 0 1 run and stop at end of buffer 1 0 load next descriptor now 1 1 run and link at end of buffer
669 32054f?avr32?09/09 at32ap7002 used for out transfers only. 0 = usb end of transfer is ignored. 1 = usba device can put an end to the current buffer transfer. when set, a bulk or interrupt short packet or the last packet of an isoc hronous (micro) frame (datax) will close the current buffe r and the dmastatusx register en d_tr_st flag will be raised. this is intended for usba non -prenegotiated end of transf er (bulk or interrupt) or isochronous microframe data buffer closure. ? end_b_en: end of buffer enable (control) 0 = dma buffer end has no impact on usb packet transfer. 1 = endpoint can validate the packet (according to the values programmed in the eptctlx register auto_valid and shrt_pckt fields) at dma buffer end, i.e. when the dmastatus register buff_count reaches 0. this is mainly for short packet in validation initiated by the dma reaching end of buffer, but could be used for out packet truncation (discarding of unwanted packet data) at the end of dma buffer. ? end_tr_it: end of transfer interrupt enable 0 = usba device initiated buffer transfe r completion will not trigger any in terrupt at statusx/end_tr_st rising. 1 = an interrupt is sent afte r the buffer tran sfer is complete, if the usba device has ende d the buffer transfer. use when the receive size is unknown. ? end_buffit: end of buffer interrupt enable 0 = dma_statusx/end_bf_st rising will not trigger any interrupt. 1 = an interrupt is generated when the dmastatusx register buff_count reaches zero. ? desc_ld_it: descriptor loaded interrupt enable 0 = dmastatusx/desc_ldst rising will not trigger any interrupt. 1 = an interrupt is generated when a descriptor has been loaded from the bus. ? burst_lck: burst lock enable 0 = the dma never locks bus access. 1 = usb packets hsb data bursts are locked for maximum opt imization of the bus bandwidth usage and maximization of fly-by hsb burst duration. ? buff_length: buffer byte length (write-only) this field determines the number of bytes to be transferred until end of buffer. the maximum channel transfer size (64 kb) is reached when this field is 0 (default value). if the transfer size is unknown, this field s hould be set to 0, but the transf er end may occur earlier under usba device control. when this field is written, the dmastatusx register buff_count fiel d is updated with the write value. note: bits [31:2] are only writable when issuin g a channel control command other than ?stop now?. note: for reliability it is highly recommended to wait for both dmastatusx register chan_act and chan_enb flags are at 0, thus ensuring the channel has been stopped befor e issuing a command other than ?stop now?.
670 32054f?avr32?09/09 at32ap7002 31.7.28 usba dma channelx status register name: dmastatusx access type: read/write ? chann_enb: channel enable status 0 = if cleared, the dma channel no longer transfers data, and may load the next descriptor if the dmacontrolx register ldnxt_dsc bit is set. when any transfer is ended either due to an elapsed byte coun t or a usba device initiated tr ansfer end, this bit is automat- ically reset. 1 = if set, the dma channel is currently enabled and transfers data upon request. this bit is normally set or cleared by writing into the dmacontrolx register ch ann_enb bit field either by software or descriptor loading. if a channel request is currently serviced when the dmacontrolx register chann_enb bit is cleared, the dma fifo buffer is drained until it is empty, then this status bit is cleared. ? chann_act: channel active status 0 = the dma channel is no longer trying to source the packet data. when a packet transfer is ended this bit is automatically reset. 1 = the dma channel is currently trying to source packet da ta, i.e. selected as the highest-priority requesting channel. when a packet transfer cannot be completed due to an end_bf_st, this flag stays set during the next channel descriptor load (if any) and potent ially until usba packet trans fer completion, if allowed by the new descriptor. ? end_tr_st: end of channel transfer status 0 = cleared automatically when read by software. 1 = set by hardware when the last packet transfer is complete, if the usba device has ended the transfer. valid until the chann_enb flag is cleared at the end of the next buffer transfer. ? end_bf_st: end of channel buffer status 0 = cleared automatically when read by software. 1 = set by hardware when the buff_count downcount reach zero. valid until the chann_enb flag is cleared at the end of the next buffer transfer. 31 30 29 28 27 26 25 24 buff_count 23 22 21 20 19 18 17 16 buff_count 15 14 13 12 11 10 9 8 ???????? 76543210 ? desc_ldst end_bf_st end_tr_st ? ? chann_act chann_enb
671 32054f?avr32?09/09 at32ap7002 ? desc_ldst: descriptor loaded status 0 = cleared automatically when read by software. 1 = set by hardware when a descriptor has been loaded from the system bus. valid until the chann_enb flag is cleared at the end of the next buffer transfer. ? buff_count: buffer byte count this field determines the current number of bytes still to be transfer red for this buffer. this field is decremented from the hsb source bus access byte width at the end of this bus address phase. the access byte width is 4 by default, or less, at dma start or end, if the start or end address is not aligned on a word boundary. at the end of buffer, the dma accesses the usba device only for the number of byte s needed to complete it. this field value is reliable (stable) only if the channel has been stopped or frozen (eptctlx register nt_dis_dma bit is used to disable the channel request) and the chann el is no longer active chann_act flag is 0. note: for out endpoints, if the receive buffer byte length (b uff_length) has been defaulted to zero because the usb transfer length is unknown, the actual buffer by te length received will be 0x10000-buff_count.
672 32054f?avr32?09/09 at32ap7002 32. timer/counter (tc) rev: 2.0.0.1 32.1 features ? three 16-bit timer counter channels ? a wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ?delay timing ? pulse width modulation ? up/down capabilities ? each channel is user-conf igurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? internal interrupt signal ? two global registers that act on all three tc channels ? peripheral event input on all a lines in capture mode 32.2 overview the timer counter (tc) includes three identical 16-bit timer counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measurement, event counting, interval measurement, pulse generation, delay timing, and pulse width modulation. each channel has three external clock inputs, fi ve internal clock inputs, and two multi-purpose input/output signals which can be configured by the user. each channel drives an internal inter- rupt signal which can be programmed to generate processor interrupts. the tc block has two global registers which act upon all three tc channels. the block control register (bcr) allows the th ree channels to be started simultaneously with the same instruction. the block mode register (bmr) defines the ex ternal clock inputs for each channel, allowing them to be chained.
673 32054f?avr32?09/09 at32ap7002 32.3 block diagram figure 32-1. tc block diagram 32.4 i/o lines description 32.5 product dependencies in order to use this module, other parts of the system must be configured correctly, as described below. 32.5.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with i/o lines. the user must first program the i/o controller to assign the tc pins to their peripheral functions. i/o contr oller tc2xc2s int0 int1 int2 tioa0 tioa1 tioa2 tiob0 tiob1 tiob2 xc2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tioa1 tioa2 tioa0 tioa2 tioa1 interrupt controller clk0 clk1 clk2 a0 b0 a1 b1 a2 b2 timer count er tiob tioa tiob sync timer_clock1 tioa sync sync tioa tiob timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc1 xc0 xc0 xc2 xc1 xc0 xc1 xc2 timer/counter channel 2 timer/counter channel 1 timer/counter channel 0 tc1xc1s tc0xc0s tioa0 table 32-1. i/o lines description pin name description type clk0-clk2 external clock input input a0-a2 i/o line a input/output b0-b2 i/o line b input/output
674 32054f?avr32?09/09 at32ap7002 when using the tioa lines as inputs the user must make sure that no peripheral events are gen- erated on the line. refer to the peripheral event system chapter for details. 32.5.2 power management if the cpu enters a sleep mode that disables cl ocks used by the tc, the tc will stop functioning and resume operation after the system wakes up from sleep mode. 32.5.3 clocks the clock for the tc bus interface (clk_tc) is generated by the power manager. this clock is enabled at reset, and can be disabled in the power manager. it is recommended to disable the tc before disabling the clock, to avoid freezing the tc in an undefined state. 32.5.4 interrupts the tc interrupt request line is connected to the interrupt controller. using the tc interrupt requires the interrupt controller to be programmed first. 32.5.5 peripheral events the tc peripheral events are connected via the pe ripheral event system. refer to the periph- eral event system chapter for details. 32.5.6 debug operation the timer counter clocks are frozen du ring debug operation, unless the ocd system keeps peripherals running in debug operation. 32.6 functional description 32.6.1 tc description the three channels of the timer counter are independent and identical in operation. the regis- ters for channel programming are listed in figure 32-3 on page 689 . 32.6.1.1 channel i/o signals as described in figure 32-1 on page 673 , each channel has the following i/o signals. 32.6.1.2 16-bit counter each channel is organized around a 16-bit counter. the value of the counter is incremented at each positive edge of the selected clock. when the counter has reached the value 0xffff and passes to 0x0000, an overflow occurs and the counter overflow status bit in the channel n sta- tus register (srn.covfs) is set. table 32-2. channel i/o signals description block/channel sign al name description channel signal xc0, xc1, xc2 external clock inputs tioa capture mode: timer counter input waveform mode: timer counter output tiob capture mode: timer counter input waveform mode: timer counter input/output int interrupt signal output sync synchronization input signal
675 32054f?avr32?09/09 at32ap7002 the current value of the counter is accessible in real time by reading the channel n counter value register (cvn). the counter can be reset by a trigger. in this case, the counter value passes to 0x0000 on the next valid edge of the selected clock. 32.6.1.3 clock selection at block level, input clock signals of each channel can either be connected to the external inputs tclk0, tclk1 or tclk2, or be connected to the configurable i/o signals a0, a1 or a2 for chaining by writing to the bmr register. see figure 32-2 on page 675 . each channel can independently select an internal or external clock source for its counter: ? internal clock signals: timer_cl ock1, timer_clock2, timer_clock3, timer_clock4, timer_clock5. see the module configuration chapter for details about the connection of these clock sources. ? external clock signals: xc0, xc1 or xc2. see the module configuration chapter for details about the connection of these clock sources. this selection is made by the clock sele ction field in the channel n mode register (cmrn.tcclks). the selected clock can be inverted with the clock invert bit in cmrn (cmrn.clki). this allows counting on the opposite edges of the clock. the burst function allows the clock to be valida ted when an external signal is high. the burst signal selection field in the cmrn regi ster (cmrn.burst) defines this signal. note: in all cases, if an external clock is used, the du ration of each of its leve ls must be longer than the clk_tc period. the external clock frequency must be at least 2.5 times lower than the clk_tc. figure 32-2. clock selection timer_clock5 xc2 tcclks clki burst 1 selected clock xc1 xc0 timer_clock4 timer_clock3 timer_clock2 timer_clock1
676 32054f?avr32?09/09 at32ap7002 32.6.1.4 clock control the clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. see figure 32-3 on page 676 . ? the clock can be enabled or disabled by the user by writing to the counter clock enable/disable command bits in the channel n clock contro l register (ccrn.clken and ccrn.clkdis). in capture mode it can be disabled by an rb load event if the counter clock disable with rb loading bit in cmrn is written to one (cmrn.ldbdis). in waveform mode, it can be disabled by an rc compare event if the counter clock disable with rc compare bit in cmrn is written to one (cmrn.cpcdis). when disabled, the start or the stop actions have no effect: only a clken command in ccrn can re-enable the clock. when the clock is enabled, the clock enabling status bit is set in srn (srn.clksta). ? the clock can also be started or stopped: a trigger (software, synchro, external or compare) always starts the clock. in capture mode the clock can be stopped by an rb load event if the counter clock stopped with rb loading bit in cmrn is written to one (cmrn.ldbstop). in waveform mode it can be stopped by an rc compare event if the counter clock stopped with rc compare bit in cmrn is written to o ne (cmrn.cpcstop). the start and the stop commands have effect only if the clock is enabled. figure 32-3. clock control 32.6.1.5 tc operating modes each channel can independently operate in two different modes: ? capture mode provides measurement on signals. ? waveform mode provides wave generation. the tc operating mode selection is done by writing to the wave bit in the ccrn register (ccrn.wave). in capture mode, tioa and tiob are configured as inputs. qs r s r q clksta clken clkdis stop event disable counter clock selected clock trigger event
677 32054f?avr32?09/09 at32ap7002 in waveform mode, tioa is always configured to be an output and tiob is an output if it is not selected to be the external trigger. 32.6.1.6 trigger a trigger resets the counter and starts the counter clock. three types of triggers are common to both modes, and a fourth external trigger is available to each mode. the following triggers are common to both modes: ? software trigger: each channel has a software trigger, available by writing a one to the software trigger command bit in ccrn (ccrn.swtrg). ? sync: each channel has a synchronization signal sync. when asserted, this signal has the same effect as a software trigger. the sync signals of all channels are asserted simultaneously by writing a one to the synchro command bit in the bcr register (bcr.sync). ? compare rc trigger: rc is implemented in each channel and can provide a trigger when the counter value matches the rc value if the rc compare trigger enable bit in cmrn (cmrn.cpctrg) is written to one. the channel can also be configured to have an external trigger. in capture mode, the external trigger signal can be selected between tioa and tiob. in waveform mode, an external event can be programmed to be one of the following si gnals: tiob, xc0, xc1, or xc2. this external event can then be programmed to perform a trigger by writing a one to the external event trig- ger enable bit in cmrn (cmrn.enetrg). if an external trigger is used, the duration of the pulses must be longer than the clk_tc period in order to be detected. regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. this means that the counter value can be read differently from zero just after a trigger, especially when a low frequency signal is selected as the clock. 32.6.1.7 peripheral events on tioa inputs the tioa input lines are ored internally with peripheral events from the peripheral event sys- tem. to capture using events the user must ens ure that the corresponding pin functions for the tioa line are disabled. when capturing on the ex ternal tioa pin the user must ensure that no peripheral events are generated on this pin. 32.6.2 capture operating mode this mode is entered by writin g a zero to the cmrn.wave bit. capture mode allows the tc channel to perform measurements such as pulse timing, fre- quency, period, duty cycle and phase on tioa and tiob sig nals which are considered as inputs. figure 32-4 on page 679 shows the configuration of the tc channel when programmed in cap- ture mode. 32.6.2.1 capture registers a and b registers a and b (ra and rb) are used as capture registers. this means that they can be loaded with the counter value when a progr ammable event occurs on the signal tioa.
678 32054f?avr32?09/09 at32ap7002 the ra loading selection field in cmrn (cmrn.ldra) defines the tioa edge for the loading of the ra register, and the rb loading selection fi eld in cmrn (cmrn.ldrb) defines the tioa edge for the loading of the rb register. ra is loaded only if it has not been loaded since the last trigger or if rb has been loaded since the last loading of ra. rb is loaded only if ra has been loaded sinc e the last trigger or t he last loading of rb. loading ra or rb before the read of the last value loaded sets the load overrun status bit in srn (srn.lovrs). in this case, the old value is overwritten. 32.6.2.2 trigger conditions in addition to the sync signal, the software trigger and the rc compare trigger, an external trig- ger can be defined. the tioa or tiob external trigger selection bit in cmrn (cmrn.abetrg) selects tioa or tiob input signal as an external trigger. the external trigger edge selection bit in cmrn (cmrn.etredg) defines the edge (rising, falling or both) detected to generate an external trig- ger. if cmrn.etrgedg is zero (none), the external trigger is disabled.
679 32054f?avr32?09/09 at32ap7002 figure 32-4. capture mode timer_clock1 xc 0 xc 1 xc 2 tcclks clki qs r s r q clksta clken clkdis burst tiob capture register a compare rc = 16-bit counter abetrg swtrg etrgedg cpctrg imr trig ldrbs ldras etrgs sr lovrs covfs sync 1 mtiob tioa mtioa l dra ldbstop if ra is not loaded or rb is loaded if ra is loaded ldbdis cpcs int ed g e det ect or ldrb clk ovf reset timer/counter channel edge detector edge detector capture register b register c timer_clock2 timer_clock3 timer_clock4 timer_clock5
680 32054f?avr32?09/09 at32ap7002 32.6.3 waveform operating mode waveform operating mode is entered by writing a one to the cmrn.wave bit. in waveform operating mode the tc channel generates one or two pwm signals with the same frequency and independently programmable duty cy cles, or generates different types of one- shot or repetitive pulses. in this mode, tioa is configured as an output and tiob is defined as an output if it is not used as an external event. figure 32-5 on page 681 shows the configuration of the tc channel when programmed in waveform operating mode. 32.6.3.1 waveform selection depending on the waveform se lection field in cmrn (cmrn. wavsel), the behavior of cvn varies. with any selection, ra, rb and rc can all be used as compare registers. ra compare is used to control the tioa output, rb compare is used to control the tiob output (if correctly configured) and rc compare is used to control tioa and/or tiob outputs.
681 32054f?avr32?09/09 at32ap7002 figure 32-5. waveform mode tcclks clki qs r s r q clksta clken clkdis cpcdis burst tiob register a compare rc = cpcstop 16-bit counter eevt eev t e d g sync swtrg en etr g wavsel imr tr i g acpc acpa aeevt aswtrg bcpc bcpb beevt bswtrg tioa mtioa tiob mtiob cpas covfs etrgs sr cpcs cpbs clk ovf reset output contr oller o utput cont r oller int 1 ed g e det ect o r timer/counter channel timer_clock1 xc 0 xc 1 xc 2 wavsel register b register c compare rb = compare ra = timer_clock2 timer_clock3 timer_clock4 timer_clock5
682 32054f?avr32?09/09 at32ap7002 32.6.3.2 wavsel = 0 when cmrn.wavsel is zero, the value of cv n is incremented fr om 0 to 0xffff. once 0xffff has been reached, the value of cvn is re set. incrementation of cvn starts again and the cycle continues. see figure 32-6 on page 682 . an external event trigger or a software trigger can reset the value of cvn. it is important to note that the trigger may occur at any time. see figure 32-7 on page 683 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 32-6. wavsel= 0 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples
683 32054f?avr32?09/09 at32ap7002 figure 32-7. wavsel= 0 with trigger 32.6.3.3 wavsel = 2 when cmrn.wavsel is two, the value of cvn is incremented from zero to the value of rc, then automatically reset on a rc compare. once the value of cvn has been reset, it is then incremented and so on. see figure 32-8 on page 684 . it is important to note that cvn can be reset at any time by an external event or a software trig- ger if both are programmed correctly. see figure 32-9 on page 684 . in addition, rc compare can stop the counter clock (cmrn.cpcstop) and/or disable the counter clock (cmrn.cpcdis = 1). time counter value rc rb ra tiob tioa counter cleared by co mpare match with 0xffff 0xffff waveform examples counter cleared by trigger
684 32054f?avr32?09/09 at32ap7002 figure 32-8. wavsel = 2 without trigger figure 32-9. wavsel = 2 with trigger 32.6.3.4 wavsel = 1 when cmrn.wavsel is one, the value of cvn is incremented from 0 to 0xffff. once 0xffff is reached, the value of cvn is decremented to 0, then re-incremented to 0xffff and so on. see figure 32-10 on page 685 . time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples counter cleared by trigger
685 32054f?avr32?09/09 at32ap7002 a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 32-11 on page 685 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cmrn.cpcstop = 1) and/or dis- able the counter clock (cmrn.cpcdis = 1). figure 32-10. wavsel = 1 without trigger figure 32-11. wavsel = 1 with trigger time counter value rc rb ra tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples counter decremented by trigger rc rb ra counter incremented by trigger
686 32054f?avr32?09/09 at32ap7002 32.6.3.5 wavsel = 3 when cmrn.wavsel is three, the value of cvn is incremented from ze ro to rc. once rc is reached, the value of cvn is decremented to zero, then re-incremented to rc and so on. see figure 32-12 on page 686 . a trigger such as an external event or a software trigger can modify cvn at any time. if a trigger occurs while cvn is incrementing, cvn then decrements. if a trigger is received while cvn is decrementing, cvn then increments. see figure 32-13 on page 687 . rc compare can stop the counter clock (cmrn.cp cstop = 1) and/or disable the counter clock (cmrn.cpcdis = 1). figure 32-12. wavsel = 3 without trigger time counter value rc rb ra tiob tioa counter cleared by compare match with rc 0xffff waveform examples
687 32054f?avr32?09/09 at32ap7002 figure 32-13. wavsel = 3 with trigger 32.6.3.6 external event/trigger conditions an external event can be programmed to be detected on one of the clock sources (xc0, xc1, xc2) or tiob. the external event selected can then be used as a trigger. the external event selection field in cmrn (cmrn.eevt) selects the external trigger. the external event edge selection field in cmrn (cmrn.eevtedg) defines the trigger edge for each of the possible external triggers (rising, fa lling or both). if cmrn.eevtedg is written to zero, no external event is defined. if tiob is defined as an ex ternal event signal (cmrn.eevt = 0), tiob is no longer used as an output and the compare register b is not used to generate waveforms and subsequently no irqs. in this case the tc channel can only generate a waveform on tioa. when an external event is defined, it can be used as a trigger by writing a one to the cmrn.enetrg bit. as in capture mode, the sync signal and the softw are trigger are also available as triggers. rc compare can also be used as a trigger depending on the cmrn.wavsel field. 32.6.3.7 output controller the output controller defines the output level changes on tioa and tiob following an event. tiob control is used only if tiob is defin ed as output (not as an external event). the following events control tioa and tiob: ? software trigger ? external event ? rc compare ra compare controls tioa and rb compare controls tiob. each of these events can be pro- grammed to set, clear or toggle the output as defined in the following fields in cmrn: time counter value tiob tioa counter decremented by compare match with rc 0xffff waveform examples rc rb ra counter decremented by trigger counter incremented by trigger
688 32054f?avr32?09/09 at32ap7002 ? rc compare effect on tiob (cmrn.bcpc) ? rb compare effect on tiob (cmrn.bcpb) ? rc compare effect on tioa (cmrn.acpc) ? ra compare effect on tioa (cmrn.acpa)
689 32054f?avr32?09/09 at32ap7002 32.7 user interface notes: 1. read-only if cmrn.wave is zero table 32-3. tc register memory map offset register register name access reset 0x00 channel 0 control register ccr0 write-only 0x00000000 0x04 channel 0 mode register cmr0 read/write 0x00000000 0x10 channel 0 counter value cv0 read-only 0x00000000 0x14 channel 0 register a ra0 read/write (1) 0x00000000 0x18 channel 0 register b rb0 read/write (1) 0x00000000 0x1c channel 0 register c rc0 read/write 0x00000000 0x20 channel 0 status register sr0 read-only 00x00000000 0x24 interrupt enable register ier0 write-only 0x00000000 0x28 channel 0 interrupt disable register idr0 write-only 0x00000000 0x2c channel 0 interrupt mask register imr0 read-only 0x00000000 0x40 channel 1 control register ccr1 write-only 0x00000000 0x44 channel 1 mode register cmr1 read/write 0x00000000 0x50 channel 1 counter value cv1 read-only 0x00000000 0x54 channel 1 register a ra1 read/write (1) 0x00000000 0x58 channel 1 register b rb1 read/write (1) 0x00000000 0x5c channel 1 register c rc1 read/write 0x00000000 0x60 channel 1 status register sr1 read-only 0x00000000 0x64 channel 1 interrupt enable register ier1 write-only 0x00000000 0x68 channel 1 interrupt disable register idr1 write-only 0x00000000 0x6c channel 1 interrupt mask register imr1 read-only 0x00000000 0x80 channel 2 control register ccr2 write-only 0x00000000 0x84 channel 2 mode register cmr2 read/write 0x00000000 0x90 channel 2 counter value cv2 read-only 0x00000000 0x94 channel 2 register a ra2 read/write (1) 0x00000000 0x98 channel 2 register b rb2 read/write (1) 0x00000000 0x9c channel 2 register c rc2 read/write 0x00000000 0xa0 channel 2 status register sr2 read-only 0x00000000 0xa4 channel 2 interrupt enable register ier2 write-only 0x00000000 0xa8 channel 2 interrupt disable register idr2 write-only 0x00000000 0xac channel 2 interrupt mask register imr2 read-only 0x00000000 0xc0 block control register bcr write-only 0x00000000 0xc4 block mode register bmr read/write 0x00000000
690 32054f?avr32?09/09 at32ap7002 32.7.1 channel control register name: ccr access type: write-only offset: 0x00 + n * 0x40 reset value: 0x00000000 ? swtrg: software trigger command 1: writing a one to this bit will perform a software tr igger: the counter is reset and the clock is started. 0: writing a zero to this bit has no effect. ? clkdis: counter cl ock disable command 1: writing a one to this bit will disable the clock. 0: writing a zero to this bit has no effect. ? clken: counter clock enable command 1: writing a one to this bit will enab le the clock if clkdis is not one. 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - - swtrg clkdis clken
691 32054f?avr32?09/09 at32ap7002 32.7.2 channel mode register: capture mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 ? ldrb: rb loading selection ? ldra: ra loading selection ?wave 1: capture mode is disabled (waveform mode is enabled). 0: capture mode is enabled. ? cpctrg: rc compare trigger enable 1: rc compare resets the counter and starts the counter clock. 0: rc compare has no effect on the counter and its clock. ? abetrg: tioa or tiob external trigger selection 1: tioa is used as an external trigger. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - ldrb ldra 15 14 13 12 11 10 9 8 wave cpctrg - - - abetrg etrgedg 76543210 ldbdis ldbstop burst clki tcclks ldrb edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa ldra edge 0 none 1 rising edge of tioa 2 falling edge of tioa 3 each edge of tioa
692 32054f?avr32?09/09 at32ap7002 0: tiob is used as an external trigger. ? etrgedg: external trigger edge selection ? ldbdis: counter clock disable with rb loading 1: counter clock is disabled when rb loading occurs. 0: counter clock is not disabled when rb loading occurs. ? ldbstop: counter clock stopped with rb loading 1: counter clock is stopped when rb loading occurs. 0: counter clock is not stopped when rb loading occurs. ? burst: burst signal selection ? clki: clock invert 1: the counter is incremented on falling edge of the clock. 0: the counter is incremented on rising edge of the clock. ? tcclks: clock selection etrgedg edge 0 none 1 rising edge 2 falling edge 3 each edge burst burst signal selection 0 the clock is not gated by an external signal 1 xc0 is anded with the selected clock 2 xc1 is anded with the selected clock 3 xc2 is anded with the selected clock tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
693 32054f?avr32?09/09 at32ap7002 32.7.3 channel mode register: waveform mode name: cmr access type: read/write offset: 0x04 + n * 0x40 reset value: 0x00000000 ? bswtrg: software trigger effect on tiob ? beevt: external event effect on tiob 31 30 29 28 27 26 25 24 bswtrg beevt bcpc bcpb 23 22 21 20 19 18 17 16 aswtrg aeevt acpc acpa 15 14 13 12 11 10 9 8 wave wavsel enetrg eevt eevtedg 76543210 cpcdis cpcstop burst clki tcclks bswtrg effect 0 none 1set 2clear 3 toggle beevt effect 0 none 1set 2clear 3 toggle
694 32054f?avr32?09/09 at32ap7002 ? bcpc: rc compare effect on tiob ? bcpb: rb compare effect on tiob ? aswtrg: software trigger effect on tioa ? aeevt: external event effect on tioa ? acpc: rc compare effect on tioa bcpc effect 0 none 1set 2clear 3 toggle bcpb effect 0 none 1set 2clear 3 toggle aswtrg effect 0 none 1set 2clear 3 toggle aeevt effect 0 none 1set 2clear 3 toggle acpc effect 0 none 1set 2clear 3 toggle
695 32054f?avr32?09/09 at32ap7002 ? acpa: ra compare effect on tioa ?wave 1: waveform mode is enabled. 0: waveform mode is disabled (capture mode is enabled). ? wavsel: waveform selection ? enetrg: external event trigger enable 1: the external event resets the counter and starts the counter clock. 0: the external event has no effect on the counter and its clock. in this case, the selected external event only controls the t ioa output. ? eevt: external event selection note: 1. if tiob is chosen as the external event signal, it is conf igured as an input and no longer generates waveforms and subse- quently no irqs . ? eevtedg: external ev ent edge selection ? cpcdis: counter clock disable with rc compare 1: counter clock is disabled when counter reaches rc. 0: counter clock is not disabled when counter reaches rc. ? cpcstop: counter clock stopped with rc compare 1: counter clock is stopped when counter reaches rc. acpa effect 0 none 1set 2clear 3 toggle wavsel effect 0 up mode without automatic trigger on rc compare 1 updown mode without automat ic trigger on rc compare 2 up mode with automatic trigger on rc compare 3 updown mode with automatic trigger on rc compare eevt signal selected as exte rnal event tiob direction 0 tiob input (1) 1 xc0 output 2 xc1 output 3 xc2 output eevtedg edge 0none 1 rising edge 2 falling edge 3 each edge
696 32054f?avr32?09/09 at32ap7002 0: counter clock is not stopped when counter reaches rc. ? burst: burst signal selection ? clki: clock invert 1: counter is incremented on falling edge of the clock. 0: counter is incremented on rising edge of the clock. ? tcclks: clock selection burst burst signal selection 0 the clock is not gated by an external signal. 1 xc0 is anded with the selected clock. 2 xc1 is anded with the selected clock. 3 xc2 is anded with the selected clock. tcclks clock selected 0timer_clock1 1timer_clock2 2timer_clock3 3timer_clock4 4timer_clock5 5xc0 6xc1 7xc2
697 32054f?avr32?09/09 at32ap7002 32.7.4 channel counter value register name: cv access type: read-only offset: 0x10 + n * 0x40 reset value: 0x00000000 ?cv: counter value cv contains the counter value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 cv[15:8] 76543210 cv[7:0]
698 32054f?avr32?09/09 at32ap7002 32.7.5 channel register a name: ra access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x14 + n * 0x40 reset value: 0x00000000 ? ra: register a ra contains the register a value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ra[15:8] 76543210 ra[7:0]
699 32054f?avr32?09/09 at32ap7002 32.7.6 channel register b name: rb access type: read-only if cmrn.wave = 0, read/write if cmrn.wave = 1 offset: 0x18 + n * 0x40 reset value: 0x00000000 ? rb: register b rb contains the register b value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rb[15:8] 76543210 rb[7:0]
700 32054f?avr32?09/09 at32ap7002 32.7.7 channel register c name: rc access type: read/write offset: 0x1c + n * 0x40 reset value: 0x00000000 ? rc: register c rc contains the register c value in real time. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 rc[15:8] 76543210 rc[7:0]
701 32054f?avr32?09/09 at32ap7002 32.7.8 channel status register name: sr access type: read-only offset: 0x20 + n * 0x40 reset value: 0x00000000 note: reading the status register will also clear th e interrupt bit for the co rresponding interrupts. ? mtiob: tiob mirror 1: tiob is high. if cmrn.wave is zero, this means that tiob pi n is high. if cmrn.wave is one, this means that tiob is driven high. 0: tiob is low. if cmrn.wave is zero, this means that tiob pi n is low. if cmrn.wave is one, this means that tiob is driven low. ? mtioa: tioa mirror 1: tioa is high. if cmrn.wave is zero, this means that tioa pin is high. if cmrn.wave is one, th is means that tioa is driven high. 0: tioa is low. if cmrn.wave is zero, this means that tioa pin is low. if cmrn.wave is one, this means that tioa is driven low. ? clksta: clock enabling status 1: this bit is set when the clock is enabled. 0: this bit is cleared when the clock is disabled. ? etrgs: external trigger status 1: this bit is set when an external trigger has occurred. 0: this bit is cleared when the sr register is read. ? ldrbs: rb loading status 1: this bit is set when an rb load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? ldras: ra loading status 1: this bit is set when an ra load has occurred and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? cpcs: rc compare status 1: this bit is set when an rc compare has occurred. 0: this bit is cleared when the sr register is read. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - - - - mtiob mtioa clksta 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
702 32054f?avr32?09/09 at32ap7002 ? cpbs: rb compare status 1: this bit is set when an rb compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? cpas: ra compare status 1: this bit is set when an ra compare has occurred and cmrn.wave is one. 0: this bit is cleared when the sr register is read. ? lovrs: load overrun status 1: this bit is set when ra or rb have been loaded at l east twice without any read of the corresponding register and cmrn.wave is zero. 0: this bit is cleared when the sr register is read. ? covfs: counter overflow status 1: this bit is set when a counter overflow has occurred. 0: this bit is cleared when the sr register is read.
703 32054f?avr32?09/09 at32ap7002 32.7.9 channel interrupt enable register name: ier access type: write-only offset: 0x24 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will set the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
704 32054f?avr32?09/09 at32ap7002 32.7.10 channel interrupt disable register name: idr access type: write-only offset: 0x28 + n * 0x40 reset value: 0x00000000 writing a zero to a bit in this register has no effect. writing a one to a bit in this register will clear the corresponding bit in imr. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
705 32054f?avr32?09/09 at32ap7002 32.7.11 channel interrupt mask register name: imr access type: read-only offset: 0x2c + n * 0x40 reset value: 0x00000000 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. a bit in this register is cleared when the corresponding bit in idr is written to one. a bit in this register is set when the corresponding bit in ier is written to one. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
706 32054f?avr32?09/09 at32ap7002 32.7.12 block control register name: bcr access type: write-only offset: 0xc0 reset value: 0x00000000 ? sync: synchro command 1: writing a one to this bit asserts the sync signal which generates a software trigger simultaneously for each of the channels . 0: writing a zero to this bit has no effect. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------sync
707 32054f?avr32?09/09 at32ap7002 32.7.13 block mode register name: bmr access type: read/write offset: 0xc4 reset value: 0x00000000 ? tc2xc2s: external clock signal 2 selection ? tc1xc1s: external clock signal 1 selection ? tc0xc0s: external cloc k signal 0 selection 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - tc2xc2s tc1xc1s tc0xc0s tc2xc2s signal connected to xc2 0tclk2 1none 2tioa0 3tioa1 tc1xc1s signal connected to xc1 0tclk1 1none 2tioa0 3tioa2 tc0xc0s signal connected to xc0 0tclk0
708 32054f?avr32?09/09 at32ap7002 1none 2tioa1 3tioa2
709 32054f?avr32?09/09 at32ap7002 33. pulse width modulation controller (pwm) rev: 1.2.0.2 33.1 features ? 4 channels ? one 20-bit counter per channel ? common clock generator providin g thirteen different clocks ? a modulo n counter providing eleven clocks ? two independent linear dividers working on modulo n counter outputs ? independent channels ? independent enable disable command for each channel ? independent clock selection for each channel ? independent period and duty cycle for each channel ? double buffering of period or duty cycle for each channel ? programmable selection of the output waveform polarity for each channel ? programmable center or left aligne d output waveform for each channel 33.2 description the pwm macrocell controls several cha nnels independently. each channel controls one square output waveform. characteristics of the output waveform such as period, duty-cycle and polarity are configurable through the user interface. each channel selects and uses one of the clocks provided by the clock generator. the cloc k generator provides several clocks resulting from the division of the pwm macrocell master clock. all pwm macrocell accesses are made through registers mapped on the peripheral bus. channels can be synchronized, to generate non overlapped waveforms. all channels integrate a double buffering system in order to prevent an unexpected output waveform while modifying the period or the duty-cycle.
710 32054f?avr32?09/09 at32ap7002 33.3 block diagram figure 33-1. pulse width modulation controller block diagram 33.4 i/o lines description each channel outputs one waveform on one external i/o line. pwm controller peripheral bus pwmx pwmx pwmx channel update duty cycle counter pwm0 channel pio interrupt controller power manager mck clock generator pb interface interrupt generator clock selector period comparator update duty cycle counter clock selector period comparator pwm0 pwm0 table 33-1. i/o line description name description type pwmx pwm waveform output for channel x output
711 32054f?avr32?09/09 at32ap7002 33.5 product dependencies 33.5.1 i/o lines the pins used for interfacing the pwm may be multiplexed with pio lines. the programmer must first program the pio controller to assign the desire d pwm pins to their peripheral function. if i/o lines of the pwm are not used by the applicati on, they can be used for other purposes by the pio controller. not all pwm outputs may be enabled. if an application requires only four channels, then only four pio lines will be as signed to pwm outputs. 33.5.2 debug operation the pwm clock is running during debug operation. 33.5.3 power management the pwm clock is generated by the power manager. before using the pwm, the programmer must ensure that the pwm clock is enabled in the power manager. however, if the application does not require pwm operations, the pwm clock can be stopped when not needed and be restarted later. in this ca se, the pwm will resume its oper ations where it left off. in the pwm description, master clock (mck) is the clock of the peripheral bus to which the pwm is connected. 33.5.4 interrupt sources the pwm interrupt line is connected to the interrupt controller. using the pwm interrupt requires the interrupt controller to be programmed first.
712 32054f?avr32?09/09 at32ap7002 33.6 functional description the pwm macrocell is primarily composed of a clock generator module and 4 channels. ? clocked by the system clock, mck, the clock generator module provides 13 clocks. ? each channel can independently choose one of the clock generator outputs. ? each channel generates an output waveform with attributes that can be defined independently for each channel through the user interface registers. 33.6.1 pwm clock generator figure 33-2. functional view of the clock generator block diagram caution: before using the pwm macrocell, the programmer must ensure that the pwm clock in the power manager is enabled. the pwm macrocell master clock, mck, is divide d in the clock generator module to provide dif- ferent clocks available for all channels. each channel can independently select one of the divided clocks. modulo n counter mck mck/2 mck/4 mck/16 mck/32 mck/64 mck/8 divider a clka diva pwm_mr mck mck/128 mck/256 mck/512 mck/1024 prea divider b clkb divb pwm_mr preb
713 32054f?avr32?09/09 at32ap7002 the clock generator is divided in three blocks: ? a modulo n counter whic h provides 11 clocks: f mck , f mck /2, f mck /4, f mck /8, f mck /16, f mck /32, f mck /64, f mck /128, f mck /256, f mck /512, f mck /1024 ? two linear dividers (1, 1/2, 1/3, ... 1/255) that provide two separate clocks: clka and clkb each linear divider can independently divide one of the clocks of the modulo n counter. the selection of the clock to be divided is made ac cording to the prea (preb) field of the pwm mode register (mr). the resulting clock clka (clk b) is the clock selected divided by diva (divb) field value in the pwm mode register (mr). after a reset of the pwm controller, diva (divb) and prea (preb) in the pwm mode register are set to 0. this implies that after reset clka (clkb) are turned off. at reset, all clocks provided by the modulo n counter are turned off except clock ?clk?. this situa- tion is also true when the pwm master cl ock is turned off through the power management controller. 33.6.2 pwm channel 33.6.2.1 block diagram figure 33-3. functional view of the channel block diagram each of the 4 channels is composed of three blocks: ? a clock selector which selects one of the clocks provided by the clock generator described in section 33.6.1 ?pwm clock generator? on page 712 . ? an internal counter clocked by the output of the clock selector. this internal counter is incremented or decremented according to the channel configuration and comparators events. the size of the internal counter is 20 bits. ? a comparator used to generate events according to the internal counter value. it also computes the pwmx output waveform according to the configuration. 33.6.2.2 waveform properties the different properties of output waveforms are: ? the internal clock selection . the internal channel counter is clocked by one of the clocks provided by the clock generator described in the previous section. this channel parameter is defined in the cpre field of the cmrx register. this field is reset at 0. ? the waveform period . this channel parameter is defined in the cprd field of the cprdx register. comparator pwmx output waveform internal counter clock selector inputs from clock generator inputs from peripheral bus channel
714 32054f?avr32?09/09 at32ap7002 - if the waveform is left aligned, then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32 , 64, 128, 256, 512, or 1024), the resulting period formula will be: by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center aligned then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024 ). the resulting period formula will be: by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or ? the waveform duty cycle . this channel parameter is defined in the cdty field of the cdtyx register. if the waveform is left aligned then: if the waveform is center aligned, then: ? the waveform polarity. at the beginning of the period, the signal can be at high or low level. this property is defined in the cpol field of t he cmrx register. by default the signal starts by a low level. ? the waveform alignment . the output waveform can be left or center aligned. center aligned waveforms can be used to generate non overlapped waveforms. this property is defined in the calg field of the cmrx register. the default mode is left aligned. xcprd () mck ------------------------------- crpd diva () mck ------------------------------------------ crpd divab () mck ---------------------------------------------- 2 x cprd () mck ---------------------------------------- - 2 cprd diva () mck --------------------------------------------------- - 2 cprd divb () mck --------------------------------------------------- - duty cycle period 1 fchannel_x_clock cdty ? ? () period ------------------------------------------------------------------------------------------------------- - = duty cycle period 2 ? () 1 fchannel_x_clock cdty ? ? ()) period 2 ? () ---------------------------------------------------------------------------------------------------------------------- - =
715 32054f?avr32?09/09 at32ap7002 figure 33-4. non overlapped center aligned waveforms note: 1. see figure 33-5 on page 716 for a detailed description of center aligned waveforms. when center aligned, the internal channel count er increases up to cprd and.decreases down to 0. this ends the period. when left aligned, the internal channel counter increases up to cprd and is reset. this ends the period. thus, for the same cprd value, the period for a ce nter aligned channel is twice the period for a left aligned channel. waveforms are fixed at 0 when: ? cdty = cprd and cpol = 0 ? cdty = 0 and cpol = 1 waveforms are fixed at 1 (once the channel is enabled) when: ? cdty = 0 and cpol = 0 ? cdty = cprd and cpol = 1 the waveform polarity must be set before enabling the channel. this immediately affects the channel output level. changes on channel polari ty are not taken into account while the channel is enabled. pwm0 pwm1 period no overlap
716 32054f?avr32?09/09 at32ap7002 figure 33-5. waveform properties pwm_mckx chidx(pwm_sr) center aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform pwmx cpol(pwm_cmrx) = 0 output waveform pwmx cpol(pwm_cmrx) = 1 chidx(pwm_isr) left aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform pwmx cpol(pwm_cmrx) = 0 output waveform pwmx cpol(pwm_cmrx) = 1 chidx(pwm_isr) calg(pwm_cmrx) = 0 calg(pwm_cmrx) = 1 period period chidx(pwm_ena) chidx(pwm_dis)
717 32054f?avr32?09/09 at32ap7002 33.6.3 pwm controller operations 33.6.3.1 initialization before enabling the output channel, this chann el must have been configured by the software application: ? configuration of the clock generator if diva and divb are required ? selection of the clock for each channel (cpre field in the cmrx register) ? configuration of the waveform alignment for each channel (calg field in the cmrx register) ? configuration of the period for each channel (cprd in the cprdx register). writing in cprdx register is possible while the channel is disabl ed. after validation of the channel, the user must use cupdx register to update cprdx as explained below. ? configuration of the duty cycle fo r each channel (cdty in the cdtyx register). writing in cdtyx register is possible while the channel is disabled. after validation of the channel, the user must use cupdx register to update cdtyx as explained below. ? configuration of the output waveform polarity for each channel (cpol in the cmrx register) ? enable interrupts (writing chidx in the ier register) ? enable the pwm channel (writing chidx in the ena register) it is possible to synchronize different channels by enabling them at the same time by means of writing simultaneously several chi dx bits in the ena register. in such a situation, all channels may have the same clock selector configuration and the same period specified. 33.6.3.2 source clock selection criteria the large number of source clocks can make selection difficult. the relationship between the value in the period register (cprdx) and the duty cycle register (cdtyx) can help the user in choosing. the event number written in the period register gives the pwm accuracy. the duty cycle quantum cannot be lower than 1/cprdx value. the higher the value of cprdx, the greater the pwm accuracy. for example, if the user sets 15 (in decimal) in cprdx, the user is able to set a value between 1 up to 14 in cdtyx register. the resulting duty cycle quantum cannot be lower than 1/15 of the pwm period. 33.6.3.3 changing the duty cycle or the period it is possible to modulate the output waveform duty cycle or period. to prevent unexpected output waveform, the user must use the update register (pwm_cupdx) to change waveform parameters while the channel is still enabled. the user can write a new period value or duty cycle value in the update re gister (cupdx). this register holds the new value until the end of the current cycle and updates the value for the next cycle. depending on the cpd field in the cmrx register, cupdx either updates cprdx or cdtyx. note that even if the update register is used, the period must not be smaller than the duty cycle.
718 32054f?avr32?09/09 at32ap7002 figure 33-6. synchronized period or duty cycle update to prevent overwriting the cupdx by software, t he user can use status events in order to syn- chronize his software. two methods are possible. in both, the user must enable the dedicated interrupt in ier at pwm controller level. the first method (polling method) consists of r eading the relevant status bit in isr register according to the enabled channel(s). see figure 33-7 . the second method uses an interrupt service routine associated with the pwm channel. note: reading the isr register automatically clears chidx flags. figure 33-7. polling method note: polarity and alignment can be modified only when the channel is disabled. pwm_cupdx value pwm_cprdx pwm_cdtyx end of cycle pwm_cmrx. cpd user's writing 1 0 writing in pwm_cupdx the last write has been taken into account chidx = 1 writing in cpd field update of the period or duty cycle pwm_isr read acknowledgement and clear previous register state yes
719 32054f?avr32?09/09 at32ap7002 33.6.3.4 interrupts depending on the interrupt mask in the imr register, an interrupt is generated at the end of the corresponding channel period. the interrupt remains active until a read operation in the isr reg- ister occurs. a channel interrupt is enabled by setting the corresponding bit in the ier register. a channel interrupt is disabled by setting the corresponding bit in the idr register.
720 32054f?avr32?09/09 at32ap7002 33.7 pulse width modulation (pwm ) controller user interface 33.7.1 register mapping table 33-2. pwm controller registers offset register name access peripheral reset value 0x00 pwm mode register mr read/write 0 0x04 pwm enable register ena write-only - 0x08 pwm disable register dis write-only - 0x0c pwm status register sr read-only 0 0x10 pwm interrupt enable register ier write-only - 0x14 pwm interrupt disable register idr write-only - 0x18 pwm interrupt mask register imr read-only 0 0x1c pwm interrupt status register isr read-only 0 0x4c - 0xf8 reserved ? ? ? 0x4c - 0xfc reserved ? ? ? 0x100 - 0x1fc reserved 0x200 channel 0 mode register cmr0 read/write 0x0 0x204 channel 0 duty cycle register cdty0 read/write 0x0 0x208 channel 0 period register cprd0 read/write 0x0 0x20c channel 0 counter register ccnt0 read-only 0x0 0x210 channel 0 update register cupd0 write-only - ... reserved 0x220 channel 1 mode register cmr1 read/write 0x0 0x224 channel 1 duty cycle register cdty1 read/write 0x0 0x228 channel 1 period register cprd1 read/write 0x0 0x22c channel 1 counter register ccnt1 read-only 0x0 0x230 channel 1 update register cupd1 write-only - ... ... ... ... ...
721 32054f?avr32?09/09 at32ap7002 33.7.2 pwm mode register register name: mr access type: read/write ? diva, divb: clka, clkb divide factor ? prea, preb 31 30 29 28 27 26 25 24 ???? preb 23 22 21 20 19 18 17 16 divb 15 14 13 12 11 10 9 8 ???? prea 76543210 diva diva, divb clka, clkb 0 clka, clkb clock is turned off 1 clka, clkb clock is clock selected by prea, preb 2-255 clka, clkb clock is clock selected by prea, preb divided by diva, divb factor. prea, preb divider input clock 0000mck. 0001mck/2 0010mck/4 0011mck/8 0100mck/16 0101mck/32 0110mck/64 0111mck/128 1000mck/256 1001mck/512 1010mck/ 1024 other reserved
722 32054f?avr32?09/09 at32ap7002 33.7.3 pwm enable register register name: ena access type: write-only ? chidx: channel id 0 = no effect. 1 = enable pwm output for channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
723 32054f?avr32?09/09 at32ap7002 33.7.4 pwm disable register register name: dis access type: write-only ? chidx: channel id 0 = no effect. 1 = disable pwm output for channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
724 32054f?avr32?09/09 at32ap7002 33.7.5 pwm status register register name: sr access type: read-only ? chidx: channel id 0 = pwm output for channel x is disabled. 1 = pwm output for channel x is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
725 32054f?avr32?09/09 at32ap7002 33.7.6 pwm interrupt enable register register name: ier access type: write-only ? chidx: channel id. 0 = no effect. 1 = enable interrupt for pwm channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
726 32054f?avr32?09/09 at32ap7002 33.7.7 pwm interrupt disable register register name: idr access type: write-only ? chidx: channel id. 0 = no effect. 1 = disable interrupt for pwm channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
727 32054f?avr32?09/09 at32ap7002 33.7.8 pwm interrupt mask register register name: imr access type: read-only ? chidx: channel id. 0 = interrupt for pwm channel x is disabled. 1 = interrupt for pwm channel x is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
728 32054f?avr32?09/09 at32ap7002 33.7.9 pwm interrupt status register register name: isr access type: read-only ? chidx: channel id 0 = no new channel period since the last read of the isr register. 1 = at least one new channel period since the last read of the isr register. note: reading isr automatically clears chidx flags. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
729 32054f?avr32?09/09 at32ap7002 33.7.10 pwm channel mode register register name: cmrx access type: read/write ? cpre: channel pre-scaler ? calg: channel alignment 0 = the period is left aligned. 1 = the period is center aligned. ? cpol: channel polarity 0 = the output waveform starts at a low level. 1 = the output waveform starts at a high level. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????cpdcpolcalg 76543210 ???? cpre cpre channel pre-scaler 0000mck 0001mck/2 0010mck/4 0011mck/8 0100mck/16 0101mck/32 0110mck/64 0111mck/128 1000mck/256 1001mck/512 1 0 1 0 mck/1024 1011clka 1100clkb other reserved
730 32054f?avr32?09/09 at32ap7002 ? cpd: channel update period 0 = writing to the cupdx will modify the duty cycle at the next period start event. 1 = writing to the cupdx will modify the period at the next period start event.
731 32054f?avr32?09/09 at32ap7002 33.7.11 pwm channel duty cycle register register name: cdty x access type: read/write only the first 20 bits (internal ch annel counter size) are significant. ? cdty: channel duty cycle defines the waveform duty cycle. this value must be defined between 0 and cprd (cprx). 31 30 29 28 27 26 25 24 cdty 23 22 21 20 19 18 17 16 cdty 15 14 13 12 11 10 9 8 cdty 76543210 cdty
732 32054f?avr32?09/09 at32ap7002 33.7.12 pwm channel period register register name: cprdx access type: read/write only the first 20 bits (internal ch annel counter size) are significant. ? cprd: channel period if the waveform is left-aligned, then the output waveform period depends on the counter source clock and can be calculated: ? by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resultin g period formula will be: ? by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center-aligned, then the output waveform period depends on the counter source clock and can be calculated: ? by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resultin g period formula will be: ? by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or 31 30 29 28 27 26 25 24 cprd 23 22 21 20 19 18 17 16 cprd 15 14 13 12 11 10 9 8 cprd 76543210 cprd xcprd () mck ------------------------------- crpd diva () mck ------------------------------------------ crpd divab () mck ---------------------------------------------- 2 x cprd () mck ---------------------------------------- - 2 cprd diva () mck --------------------------------------------------- - 2 cprd divb () mck --------------------------------------------------- -
733 32054f?avr32?09/09 at32ap7002 33.7.13 pwm channel counter register register name: ccntx access type: read-only ? cnt: channel counter register internal counter value. this register is reset when: ? the channel is enabled (writing chidx in the ena register). ? the counter reaches cprd value defined in the cp rdx register if the wa veform is left aligned. 31 30 29 28 27 26 25 24 cnt 23 22 21 20 19 18 17 16 cnt 15 14 13 12 11 10 9 8 cnt 76543210 cnt
734 32054f?avr32?09/09 at32ap7002 33.7.14 pwm channel update register register name: cupdx access type: write-only this register acts as a double buffer for the period or the duty cycle. this prevents an unexpected waveform when modify- ing the waveform period or duty-cycle. only the first 20 bits (internal chan nel counter size) are significant. 31 30 29 28 27 26 25 24 cupd 23 22 21 20 19 18 17 16 cupd 15 14 13 12 11 10 9 8 cupd 76543210 cupd cpd (cmrx register) 0 the duty-cycle (cdty in the cdtyx register) is updated with the cupd value at the beginning of the next period. 1 the period (cprd in the cprdx register) is upda ted with the cupd value at the beginning of the next period.
735 32054f?avr32?09/09 at32ap7002 34. lcd controller (lcdc) rev: 1.7.0.3 34.1 features ? stn panel features ? single and dual scan color and monochrome lcd panels ? 4-bit single scan, 8-bit single or du al scan, 16-bit dual scan interfaces ? up to 16 gray levels for monochrome and up to 4096 colors for color panel ? 1 or 2 bits per pixel (palletized), 4 bits per pixel (non-palletized) for monochrome ? 1, 2, 4 or 8 bits per pixel (palletized), 16 bits per pixel (non-palletized) for color stn display ? tft panel features ? single scan active tft lcd panel ? up to 24-bit single scan interfaces ? 1, 2, 4 or 8 bits per pixel (palletized) , 16 or 24 bits per pixel (non-palletized) ? common features ? configurable screen si ze up to 2048 x 2048 ? dma controller for reading the disp lay data from an external memory ? 2k bytes input fifo ? 2d frame buffer addressing allowing movement in an image larger than the screen size 34.2 description the lcd controller consists of logic for trans ferring lcd image data from an external display buffer to an lcd module with integrated common and segment drivers. the lcd controller supports single and double scan monochrome and color passive stn lcd modules and single scan active tft lcd modules. on monochrome stn displays, up to 16 gray shades are supported using a time-based dithering algorithm and frame rate control (frc) method. this method is also used in colo r stn displays to generate up to 4096 colors. the lcd controller has a display input buffer (fifo) to allow a flexible connection of the exter- nal high speed bus master interface, and a lookup table to allow palletized display configurations. the lcd controller is programmable in order to support many different requirements such as resolutions up to 2048 x 2048; pixel depth (1, 2, 4, 8, 16, 24 bits per pixel); data line width (4, 8, 16 or 24 bits) and interface timing. the lcd controller is connected to the high s peed bus (hsb) as a master for reading pixel data. however, the lcd controller interfaces with the hsb as a slave in order to configure its registers.
736 32054f?avr32?09/09 at32ap7002 34.3 block diagram figure 34-1. lcd macrocell block diagram timegen pwm display cfg ch-l hsb if ch-u ctrl cfg hsb slave display if hsb master split lut mem fifo mem dma controller lcd controller core configuration if control interface lower push fifo serializer palette dithering output shifter hsb slave hsb slave input interface upper push dma data lcdd display if control signals dvalid dvalid hsb clock domain lcdc core clock domain lut mem interface fifo mem interface lut mem interface data pat h
737 32054f?avr32?09/09 at32ap7002 34.4 i/o lines description 34.5 product dependencies 34.5.1 i/o lines the pins used for interfacing the lcd controller may be multiplexed with pio lines. the pro- grammer must first program the pio controller to assign the pins to their peripheral function. if i/o lines of the lcd controller are not used by the application, they can be used for other pur- poses by the pio controller. 34.5.2 power management the lcdc core clock, which is used to generate the pclk output and the other lcd synchro- nization signals, is driven by a generic clock output in the power manager. before using the lcdc, the programmer must ensur e that the corr ect generic clock is e nabled in the power man- ager. the generic clock number used for the lcdc is listed in the power manager chapter. 34.5.3 interrupt sources the lcd interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the lcd. 34.5.4 clock management when the lcdc is being used in a system with sdram, the sdram clock frequency must be greater than the frequency of the lcdc core clock. 34.6 functional description the lcd controller consists of two main blocks ( figure 34-1 on page 736 ), the dma controller and the lcd controller core (lcdc core). the dma controller reads the display data from an external memory through a hsb master interface. the lcd controller core formats the display data. the lcd controller core continuously pumps the pixel data into the lcd module via the lcd data bus (lcdd[23:0]); this bus is timed by the pclk, dval, hsync, and vsync signals. table 34-1. i/o lines description name description type cc contrast control signal output hsync line synchronous signal (stn) or horizontal synchronous signal (tft) output pclk lcd pixel clock signal (stn/tft) output vsync frame synchronous signal (stn) or ve rtical synchronizati on signal (tft) output dval stn ac bias signal for the driver or data enable signal (tft) output mod lcd modulation signal output pwr lcd panel power enable control signal output gp[7:0] lcd general purpose lines output lcdd[23:0] lcd data bus output output
738 32054f?avr32?09/09 at32ap7002 34.6.1 dma controller 34.6.1.1 configuration block the configuration block is a set of programmable registers that are used to configure the dma controller operation. these registers are written vi a the hsb slave interface. only word access is allowed. for details on the configuration registers, see ?lcd controller (lcdc) user interface? on page 767 . 34.6.1.2 hsb interface this block generates the hsb transactions. it generates undefined-length incrementing bursts as well as 4- ,8- or 16-beat incrementing bursts. the size of the transfer can be configured in the brstlen field of the dmafrmcfg register. for details on this register, see ?dma frame con- figuration register? on page 775 . 34.6.1.3 channel-u this block stores the base address and the number of words transferred for this channel (frame in single scan mode and upper panel in dual scan mode) since the beginning of the frame. it also generates the end of frame signal. it has two pointers, the base address and the number of words to transfer. when the module receives a new_frame signal, it reloads the number of words to transfer pointer with the size of the frame/panel. when the module receives the new_frame signal, it also reloads the base address with the base address programmed by the host. the size of the frame/panel can be programmed in the frmsize field of the dmafrmcfg register. this size is calculated as follows: ?in tft mode: ?in stn monochrome mode: ?in stn color mode: where: ?lineval is the value of the lineval field of the lcdfrmcfg register of lcd controller ?hozval is the value of the hozval field of the lcdfrmcfg register of the lcd controller ?e_ifwidth is the number of data bits in the lcd interface for each panel ?bpp is the bits per pixel configuration frame_size display_size bpp 32 -------------------------------------------------- = frame_size lineval 1 + () hozval 1 + () e_ifwidth bpp 32 ------------------------------------------------------------------------------------------------------------------------------- ---- = frame_size lineval 1 + () hozval 1 + () e_ifwidth 3 -------------------------------------------------------------------- - ?? ?? bpp 32 ----------------------------------------------------------------------------------------------------------------------------- = frame_size x_size*y_size 32 ------------------------------------- - =
739 32054f?avr32?09/09 at32ap7002 x_size = ((linesize +1)*bpp+pixeloff)/32 y_size = (lineval+1) ?linesize is the horizontal size of the display in pixels, minus 1, as programmed in the linesize field of the lcdfrmcfg register of the lcd controller. ?bpp is the number of bits per pixel configured. ?pixeloff is the pixel offset for 2d addressing, as programmed in the dma2dcfg register. applicable only if 2d addressing is being used. ?lineval is the vertical size of the display in pixels, minus 1, as programmed in the lineval field of the lcdfrmcfg register of the lcd controller. note: x_size is calculated as an up-rounding of a division by 32. (this can also be done adding 31 to the dividend before using an integer division by 32). when using the 2d-addressing mode (see ?2d memory addressing? on page 761 ), it is important to note that the above calculation must be exe- cuted and the frmsize field programmed with ever y movement of the displaying window, since a change in the pixeloff field can change the resulting frmsize value. 34.6.1.4 channel-l this block has the same functionality as channel- u, but for the lower panel in dual scan mode only. 34.6.1.5 control this block receives the request signals from the lcdc core and generates the requests for the channels. 34.6.2 lcd controller core 34.6.2.1 configuration block the configuration block is a set of programmable registers that are used to configure the lcdc core operation. these registers are written via the hsb slave interface. only word access is allowed. the description of the configuration registers can be found in ?lcd controller (lcdc) user interface? on page 767 . 34.6.2.2 datapath the datapath block contains five submodules: fif o, serializer, palette, dithering and shifter. the structure of the datapath is shown in figure 34-2 .
740 32054f?avr32?09/09 at32ap7002 figure 34-2. datapath structure this module transforms the data read from the memory into a format according to the lcd mod- ule used. it has four different interfaces: the input interface, the output interface, the configuration interface and the control interface. ?the input interface connects the datapath with the dma controller. it is a dual fifo interface with a data bus and two push lines that are used by the dma controller to fill the fifos. ?the output interface is a 24-bit data bus. the configuration of this interface depends on the type of lcd used (tft or stn, single or dual scan, 4-bit, 8-bit, 16-bit or 24-bit interface). ?the configuration interface connects the datapath with the configuration block. it is used to select between the different datapath configurations. ?the control interface connects the datapath with the timing generation block. the main control signal is the data-request signal, used by the timing generation module to request new data from the datapath. the datapath can be characterized by two parameters: initial_latency and cycles_per_data. the parameter initial_latency is defin ed as the number of lcdc core clock cycles until the first data is available at the output of the datapath. th e parameter cycles_per_data is the minimum num- ber of lcdc core clock cycles between two consecutive data at the output interface. fifo serializer palette dithering output shifter input interface output interface configuration if control interface
741 32054f?avr32?09/09 at32ap7002 these parameters are different for the different configurations of the lcd controller and are shown in table 34-2 . 34.6.2.3 fifo the fifo block buffers the input data read by the dma module. it contains two input fifos to be used in dual scan configuration that are configured as a single fifo when used in single scan configuration. the size of the fifos allows a wide range of architectures to be supported. the upper threshold of the fifos can be configured in the fifoth field of the lcdfifo regis- ter. the lcdc core will request a dm a transfer when the number of words in each fifo is less than fifoth words. to avoid overwriting in the fifo and to maximize the fifo utilization, the fifoth should be programmed with: fifoth = lcd_fifo_size - (2 x dma_burst_length + 3) where: ?lcd_fifo_size is the effective size of the fifo. it is the total fifo memory size in single scan mode and half that size in dual scan mode. ?dma_burst_length is the burst length of the transfers made by the dma 34.6.2.4 serializer this block serializes the data read from memory. it reads words from the fifo and outputs pix- els (1 bit, 2 bits, 4 bits, 8 bits, 16 bits or 24 bits wide) depending on the format specified in the pixelsize field of the lcdcon2 register. it also adapts the memory-ordering format. both big- endian and little-endian formats are supported. they are configured in the memor field of the lcdcon2 register. the organization of the pixel data in the memory depends on the configur ation and is shown in table 34-3 and table 34-4 . note: for a color depth of 24 bits per pixel ther e are two different formats supported: packed and unpacked. the packed format needs less memory but has some limitations when working in 2d addressing mode ( see section ?34. 10? on page 761. ). table 34-2. datapath parameters configuration initial_latency cycles_per_data distype scan ifwidth tft 9 1 stn mono single 4 13 4 stn mono single 8 17 8 stn mono dual 8 17 8 stn mono dual 16 25 16 stn color single 4 11 2 stn color single 8 12 3 stn color dual 8 14 4 stn color dual 16 15 6
742 32054f?avr32?09/09 at32ap7002 table 34-3. little endian memory organization mem addr 0x3 0x2 0x1 0x0 bit 3 1 3 0 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9876543210 pixel 1bpp 3 1 3 0 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9876543210 pixel 2bpp 1514131211109876543210 pixel 4bpp 76543210 pixel 8bpp 3210 pixel 16bpp 10 pixel 24bpp 10 pixel 24bpp 21 pixel 24bpp 32 pixel 24bpp 54 table 34-4. big endian memory organization mem addr 0x3 0x2 0x1 0x0 bit 3 1 3 0 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9876543210 pixel 1bpp 0123456789 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 pixel 2bpp 0123456789101112131415 pixel 4bpp 01234567 pixel 8bpp 0123 pixel 16bpp 01 pixel 24bpp packed 01 pixel 24bpp packed 12
743 32054f?avr32?09/09 at32ap7002 34.6.2.5 palette this block is used to generate the pixel gray or color information in palletized configurations. the different modes with the palletized/non-palletized configuration can be found in table 34-6 . in pixel 24bpp packed 23 pixel 24bpp packed 45 pixel 24bpp unpacke d not used 0 table 34-4. big endian memory organization mem addr 0x3 0x2 0x1 0x0 table 34-5. wince pixel memory organization mem addr 0x3 0x2 0x1 0x0 bit 3 1 3 0 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 0 9876543210 pixel 1bpp 2 4 2 5 2 6 2 7 2 8 2 9 3 0 3 1 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 89 1 0 1 1 1 2 1 3 1 4 1 5 01234567 pixel 2bpp 1213141589101145670123 pixel 4bpp 67452301 pixel 8bpp 3210 pixel 16bpp 10 pixel 24bpp packed 10 pixel 24bpp packed 21 pixel 24bpp packed 32 pixel 24bpp unpacke d not used 0
744 32054f?avr32?09/09 at32ap7002 these modes, 1, 2, 4 or 8 input bits index an entry in the lookup table. the corresponding entry in the lookup table contains the color or gray shade information for the pixel. the lookup table can be accessed by the host in r/w mode to allow the host to program and check the values stored in the palette. it is mapped in the lcd controller configuration memory map. the lut is mapped as 16-bit half-words aligned at word boundaries, only word write access is allowed (the 16 msb of the bus are not used). for the detailed memory map, see table 34-13 on page 767 . the lookup table contains 256 16 -bit wide entries. the 256 entries are chosen by the program- mer from the 2 16 possible combinations. for the structure of each lut entry, see table 34-7 . in stn monochrome, only the four most signifi cant bits of the red value are used (16 gray shades). in stn color, only the four most signi ficant bits of the blue, green and red value are used (4096 colors). in tft mode, all the bits in the blue, green and red values are used (32768 colors). in this mode, there is also a common intensity bit that can be used to double the possible colors. this bit is the least significant bit of each color component in the lcdd interface (lcdd[18], lcdd[10], lcdd[2]). the lcdd unused bits are tied to 0 when tft palletized configurations are used (lcdd[17:16], lcdd[ 9:8], lcdd[1:0]). 34.6.2.6 dithering the dithering block is used to generate the shades of gray or color when the lcd controller is used with an stn lcd module. it uses a time-based dithering algorithm and frame rate con- trol method. table 34-6. palette configurations configuration palette distype pixelsize tft 1, 2, 4, 8 palletized tft 16, 24 non-palletized stn mono 1, 2 palletized stn mono 4 non-palletized stn color 1, 2, 4, 8 palletized stn color 16 non-palletized table 34-7. lookup table structure in the memory address data output [15:0] 00 intensity_bit_0 blue_value_0[4:0] green_value_0[4:0] red_value_0[4:0] 01 intensity_bit_1 blue_value_1[4:0] green_value_1[4:0] red_value_1[4:0] ... fe intensity_bit_254 blue_value_254[4: 0] green_value_254[4:0] red_value_254[4:0] ff intensity_bit_255 blue_value_255[4: 0] green_value_255[4:0] red_value_255[4:0]
745 32054f?avr32?09/09 at32ap7002 the frame rate control varies the duty cycle for which a given pixel is turned on, giving the dis- play an appearance of multiple shades. in order to reduce the flicker noise caused by turning on and off adjacent pixels at the same time, a time-based dithering algorithm is used to vary the pattern of adjacent pixels every frame. this algorithm is expressed in terms of dithering pattern registers (dp_i) and considers not only the pixel gray level number, but also its horizontal coordinate. table 34-8 shows the correspondences between the gray levels and the duty cycle. the duty cycles for gray levels 0 and 15 are 0 and 1, respectively. the same dp_i register can be used for the pairs for which the sum of duty cycles is 1 (e.g., 1/7 and 6/7). the dithering pattern for the first pair member is the inversion of the one for the second. the dp_i registers contain a series of 4-bit patterns. the (3-m) th bit of the pattern determines if a pixel with horizontal coordinate x = 4n + m (n is an integer and m ranges from 0 to 3) should be turned on or off in the current frame. the operation is shown by the examples below. consider the pixels a, b, c and d with the horizontal coordinates 4*n+0, 4*n+1, 4*n+2 and 4*n+3, respectively. the four pixels should be displayed in gray level 9 (duty cycle 3/5) so the register used is dp3_5 =?1010 0101 1010 0101 1111?. table 34-8. dithering duty cycle gray level duty cycle pattern register 15 1 - 14 6/7 dp6_7 13 4/5 dp4_5 12 3/4 dp3_4 11 5/7 dp5_7 10 2/3 dp2_3 9 3/5 dp3_5 8 4/7 dp4_7 71/2~dp1_2 63/7~dp4_7 52/5~dp3_5 41/3~dp2_3 31/4~dp3_4 21/5~dp4_5 11/7~dp6_7 00-
746 32054f?avr32?09/09 at32ap7002 the output sequence obtained in the data output for monochrome mode is shown in table 34-9 . consider now color display mode and two pixels p0 and p1 with the horizontal coordinates 4*n+0, and 4*n+1. a color pixel is composed of three components: {r, g, b}. pixel p0 will be dis- played sending the color components {r0, g0, b0 } to the display. pixe l p1 will be displayed sending the color components {r1, g1, b1}. suppose that the data read from memory and mapped to the lookup tables corresponds to shade level 10 for the three color components of both pixels, with the dithering pattern to apply to all of them being dp2_3 = ?1101 1011 0110?. table 34-10 shows the output sequence in the data output bus for single scan configurations. (in dual scan configuration, each panel data bus acts like in the equivalent single scan configuration.) table 34-9. dithering algorithm for monochrome mode frame number pattern pixel a pixel b pixel c pixel d n 1010 on off on off n+1 0101 off on off on n+2 1010 on off on off n+3 0101 off on off on n+4 1111 on on on on n+5 1010 on off on off n+6 0101 off on off on n+7 1010 on off on off ... ... ... ... ... ... table 34-10. dithering algorithm for color mode frame signal shadow level bit used dithering pattern 4-bit lcdd 8-bit lcdd output n red_data_0 1010 3 1101 lcdd[3] lcdd[7] r0 n green_data_0 1010 2 1101 lcdd[2] lcdd[6] g0 n blue_data_0 1010 1 1101 lcdd[1] lcdd[5] b0 n red_data_1 1010 0 1101 lcdd[0] lcdd[4] r1 n green_data_1 1010 3 1101 lcdd[3] lcdd[3] g1 n blue_data_1 1010 2 1101 lcdd[2] lcdd[2] b1 ?? ? ? ? ? ?? n+1 red_data_0 1010 3 1011 lcdd[3] lcdd[7] r0 n+1 green_data_0 1010 2 1011 lcdd[2] lcdd[6] g0 n+1 blue_data_0 1010 1 1011 lcdd[1] lcdd[5] b0 n+1 red_data_1 1010 0 1011 lcdd[0] lcdd[4] r1 n+1 green_data_1 1010 3 1011 lcdd[3] lcdd[3] g1 n+1 blue_data_1 1010 2 1011 lcdd[2] lcdd[2] b1 ?? ? ? ? ? ?? n+2 red_data_0 1010 3 0110 lcdd[3] lcdd[7] r0
747 32054f?avr32?09/09 at32ap7002 note: ri = red pixel component on. gi = green pixel component on. bi = blue pixel component on. ri = red pixel component off. gi = green pixel component off. bi = blue pixel component off. 34.6.2.7 shifter the fifo, serializer, palette and dithering modules process one pixel at a time in monochrome mode and three sub-pixels at a time in color mode (r,g,b components). this module packs the data according to the output interfac e. this interface can be programmed in the distype, scanmod, and ifwidth fields of the lcdcon2 register. the distype field selects between tft, stn mo nochrome and stn color display. the scan- mode field selects between single and dual sc an modes; in tft mode, only single scan is supported. the ifwidth field configures the width of the interface in stn mode: 4-bit (in single scan mode only), 8-bit and 16-bit (in dual scan mode only). for a more detailed description of the fields, see ?lcd controller (lcdc) user interface? on page 767 . for a more detailed description of the lcd interface, see ?lcd interface? on page 753 . 34.6.2.8 timegen the time generator block ge nerates the c ontrol signals pclk, hsync, vsync, dval, and mode, used by the lcd module. this block is programmable in order to support different types of lcd modules and obtain the output clock signals, which are derived from the lcdc core clock. the mode signal provides an ac signal for the display. it is used by the lcd to alternate the polarity of the row and column voltages used to turn the pixels on and off. this prevents the liq- uid crystal from degradation. it can be configured to toggle every frame (bit mmode = 0 in lcdmval register) or to toggle every programmable number of hsync pulses (bit mmode = 1, number of pulses defined in mval field of lcdmval register). figure 34-3 and figure 34-4 on page 748 show the timing of mode in both configurations. n+2 green_data_0 1010 2 0110 lcdd[2] lcdd[6] g0 n+2 blue_data_0 1010 1 0110 lcdd[1] lcdd[5] b0 n+2 red_data_1 1010 0 0110 lcdd[0] lcdd[4] r1 n+2 green_data_1 1010 3 0110 lcdd[3] lcdd[3] g1 n+2 blue_data_1 1010 2 0110 lcdd[2] lcdd[2] b1 ?? ? ? ? ? ?? table 34-10. dithering algorithm for color mode (continued) frame signal shadow level bit used dithering pattern 4-bit lcdd 8-bit lcdd output f lcd_mode f lcd_hsync 2 mval 1 + () ---------------------------------------- =
748 32054f?avr32?09/09 at32ap7002 figure 34-3. full frame timing, mmode=1, mval=1 figure 34-4. full frame timing, mmode=0 the pclk signal is used to clock the data into the lcd drivers' shift register. the data is sent through lcdd[23:0] synchro nized by default with the pclk fa lling edge (rising edge can be selected). the clkval field of lcdcon1 register controls the rate of this signal. the divisor can also be bypassed with the by pass bit in the lcdcon1 register. in this case, the rate of pclk is equal to the frequency of the lcdc core clock. the minimum period of the pclk sig- nal depends on the configuration. this information can be found in table 34-11 . the pclk signal has two different timings that are selected with the clkmod field of the lcdcon2 register: ?always active (used with tft lcd modules) ?active only when data is ava ilable (used with stn lcd modules) table 34-11. minimum pclk period in lcdc core clock cycles configuration pclk period distype scan ifwidth tft 1 stn mono single 4 4 stn mono single 8 8 stn mono dual 8 8 stn mono dual 16 16 stn color single 4 2 lcd_vsync lcd_mode lcd_pclk line1 line2 line3 line4 line5 lcd_vsync lcd_mode lcd_pclk line1 line2 line3 line4 line5 f lcd_pclk f lcdc_clock 2 clkval -------------------------------- =
749 32054f?avr32?09/09 at32ap7002 the dval signal indicates valid data in the lcd interface. after each horizontal line of data has been shifted into the lcd, the hsync is asserted to cause the line to be displayed on the panel. the following timing parameters can be configured: ?vertical to horizontal delay (vhdly): the delay between begin_of_line and the generation of hsync is configurable in the vhdly field of the lcdtim1 register. the delay is equal to (vhdly+1) pclk cycles. ?horizontal pulse width (hpw): the hsync pulse width is configurable in hpw field of lcdtim2 register. the width is equal to (hpw + 1) pclk cycles. ?horizontal back porch (hbp): the delay betw een the hsync falling edge and the first pclk rising edge with valid data at the lcd interface is configurable in the hbp field of the lcdtim2 register. the delay is equal to (hbp+1) pclk cycles. ?horizontal front porch (hfp): the delay between end of valid data and the end of the line is configurable in the hfp field of the lcdtim2 register. the delay is equal to (hfp+1) pclk cycles. there is a limitation in the minimum values of vhdly, hpw and hbp parameters imposed by the initial latency of the datapath. the total de lay in lcdc core clock cycles must be higher than or equal to the latency column in table 34-2 on page 741 . this limitation is given by the fol- lowing formula: 34.6.2.9 equation 1 where: ?vhdly, hpw, hbp are the value of the fields of lcdtim1 and lcdtim2 registers ?pclk_period is the period of pclk sign al measured in l cdc core clock cycles ?dpath_latency is the datapath latency of the configuration, given in table 34-2 on page 741 the vsync is asserted once per fr ame. this signal is asserted to cause the lcd's line pointer to start over at the top of the display. the timing of this signal depends on the type of lcd: stn or tft lcd. in stn mode, the high phase corresponds to the complete first line of the frame. in stn mode, this signal is synchronized with the fi rst active pclk rising edge in a line. in tft mode, the high phase of this signal starts at the beginning of the first line. the following timing parameters can be selected: ?vertical pulse width (vpw): vsync pulse width is configurable in vpw field of the lcdtim1 register. the pulse width is equal to (vpw+1) lines. stn color single 8 2 stn color dual 8 4 stn color dual 16 6 table 34-11. minimum pclk period in lcdc core clock cycles configuration pclk period distype scan ifwidth vhdly hpw hbp 3 +++ () pclk_period dpath_latency
750 32054f?avr32?09/09 at32ap7002 ?vertical back porch: number of inactive lines at the beginning of the frame is configurable in vbp field of lcdtim1 register. the number of inactive lines is e qual to vbp. this field should be programmed with 0 in stn mode. ?vertical front porch: number of inactive lines at the end of the frame is configurable in vfp field of lcdtim2 register. the number of inactive lines is equal to vfp. this field should be programmed with 0 in stn mode. there are two other parameters to configure in this module, the hozval and the lineval fields of the lcdfrmcfg: ?hozval configures the number of active pclk cycles in each line. the number of active cycles in each line is equal to (hozval+1) cycles. the minimum value of this parameter is 1. ?lineval configures the number of active lines per frame. this number is equal to (lineval+1) lines. the minimum value of this parameter is 1. figure 34-5 , figure 34-6 and figure 34-7 show the timing of mode, pclk, dval, hsync and vsync signals: figure 34-5. stn panel timing, clkmod 0 lcd_hsync lcd_vsync lcd_mode lcd_dval lcd_pclk lcdd frame period vhdly+ hbp+1 hpw+1 hfp+1 hozval+1 lcd_pclk lcdd 1 pclk 1/2 pclk 1/2 pclk line period lcd_vsync lcd_mode lcd_hsync lcd_dval
751 32054f?avr32?09/09 at32ap7002 figure 34-6. tft panel timing, clkmod = 0, vpw = 2, vbp = 2, vfp = 1 figure 34-7. tft panel timing (line expanded view), clkmod=1 usually the frm rate is about 70 hz to 75 hz. it is given by the following equation: where: ?hozval determines de number of pclk cycles per line ?lineval determines the number of hsync cycles per frame, according to the expressions shown below: in stn mode: vhdly+1 hbp+1 hpw+1 hfp+1 hozval+1 lcd_pclk lcdd 1 pclk 1/2 pclk 1/2 pclk line period lcd_vsync lcd_hsync lcd_dval (vpw+1) lines lcd_vsync lcd_pclk lcdd lcd_dval vhdly+1 lcd_hsync vertical fron t porch = vfp lines vertical back porch = vbp lines frame period vhly+1 vbp+1 hpw+1 vfp+1 hozval+1 lcd_pclk lcdd 1 pclk 1/2 pclk 1/2 pclk line period lcd_vsync lcd_hsync lcd_dval 1 f lcd_vsync ---------------------- vhdly hpw hbp hozval hfp 5 +++ ++ f lcd_pclk --------------------------------------------------------------------------------------------------------------------- ?? ?? vbp lineval vfp 1 +++ () = hozval horizontal_display_size number_data_lines -------------------------------------------------------------- - 1 ? =
752 32054f?avr32?09/09 at32ap7002 in monochrome mode, horizontal_display_size is equal to the number of horizontal pixels. the number_data_lines is equal to the number of bits of the interface in single scan mode; number_data_lines is equal to half the bits of the interface in dual scan mode. in color mode, horizontal_display_size equals three times the number of horizontal pixels. in tft mode: the frame rate equation is used first without considering the clock periods added at the end beginning or at the end of each line to determine, approximately, the pclk rate: with this value, the clkval is fixed, as well as the corresponding pclk rate. then select vhdly, hpw and hbp according to the type of lcd used and ?equation 1? on page 749 . finally, the frame rate is adjusted to 70 hz - 75 hz with the hfp value: the line counting is controlled by the read-only field linecnt of lcdcon1 register. the line- cnt field decreases by one unit at each falling edge of hsync. 34.6.2.10 display this block is used to configure the polarity of the data and control signals. the polarity of all clock signals can be configured by lcdcon2[12:8] register setting. the block also generates the lcd_pwr output that can be used to turn the lcd module on and off by software. this signal is controlled by the pwrcon register and respects the number of frames configured in the guard_time field of pwrcon register (pwrcon[7:1]) between the write access to lcd_pwr field (pwrcon[0]) and the activation/deactivation of lcd_pwr out- put signal. the minimum value for the guard_ti me field is one frame. this gives the dma controller enough time to fill the fifos before the start of data transfer to the lcd. 34.6.2.11 pwm this block generates the lcd contrast control signal (cc) to make possible the control of the display's contrast by software. this is an 8-bit pwm (pulse width modulation) signal that can be converted to an analog voltage with a simple passive filter. the pwm module has a free-running counter whose value is compared against a compare reg- ister (contrast_val register). if the value in the counter is less than that in the register, the output brings the value of the polarity (pol) bit in the pwm control register: contrast_ctr. otherwise, the opposite value is output. thus, a periodic waveform with a pulse width propor- tional to the value in the compare register is generated. lineval vertical_display_size 1 ? = hozval horizontal_display_size 1 ? = lineval vertical_display_size 1 ? = f lcd_pclk hozval 5 + () f lcd_vsync lineval 1 + () () = hfp f pclk 1 f lcd_vsync lineval vbp vfp 1 +++ () -------------------------------------------------------------------------------------------------------- - vhdly vpw vbp hozval 5 +++ + () ? =
753 32054f?avr32?09/09 at32ap7002 due to the comparison mechanism, the output pulse has a width between zero and 255 pwm counter cycles. thus by adding a simple passive filter outside the chip, an analog voltage between 0 and (255/256) vdd can be obtained (for the positive polarity case, or between (1/256) vdd and vdd for the negative polarity case). other voltage values can be obtained by adding active external circuitry. for pwm mode, the frequency of the counter can be adjusted to four different values using field ps of contrast_ctr register. 34.6.3 lcd interface the lcd controller interfaces with the lcd module through the lcd interface ( table 34-12 on page 758 ). the controller supports the following interface configurations: 24-bit tft single scan, 16-bit stn dual scan mono (color), 8-bit stn dual (single) scan mono (color), 4-bit sin- gle scan mono (color). a 4-bit single scan stn display us es 4 parallel data lines to shift data to successive single hori- zontal lines one at a time until the entire frame has been shifted and transferred. the 4 lsb pins of lcd data bus (lcdd [3:0]) can be directly connected to the lcd driver; the 20 msb pins (lcdd [23:4]) are not used. an 8-bit single scan stn display uses 8 parallel data lines to shift data to successive single hor- izontal lines one at a time until the entire frame has been shifted and transferred. the 8 lsb pins of lcd data bus (lcdd [7:0]) can be directly connected to the lcd driver; the 16 msb pins (lcdd [23:8]) are not used. an 8-bit dual scan stn display uses two sets of 4 parallel data lines to shift data to successive upper and lower panel horizontal lines one at a time until the entire frame has been shifted and transferred. the bus lcdd[3:0] is connected to the upper panel data lines and the bus lcdd[7:4] is connected to the lower panel data lines. the re st of the lcd data bus lines (lcdd[23:8]) are not used. a 16-bit dual scan stn display uses two sets of 8 parallel data lines to shift data to successive upper and lower panel horizontal lines one at a time until the entire frame has been shifted and transferred. the bus lcdd[7:0] is connected to the upper panel data lines and the bus lcdd[15:8] is connected to the lower panel data lines. the rest of the lcd data bus lines (lcdd[23:16]) are not used. stn mono displays require one bit of image data per pixel. stn color displays require three bits (red, green and blue) of image data per pixel, resu lting in a horizontal shift register of length three times the number of pixels per horizontal line. this rgb or monochrome data is shifted to the lcd driver as consecutive bits via the parallel data lines. a tft single scan display uses up to 24 parallel data lines to shift data to successive horizontal lines one at a time until the entire frame has been shifted and transferred. the 24 data lines are divided in three bytes that define the color shade of each color component of each pixel. the lcdd bus is split as lcdd[23:16 ] for the blue component, lcdd [15:8] for the green component and lcdd[7:0] for the red component. if the lcd module has lower color resolution (fewer bits per color component), only the most significant bits of each component are used. all these interfaces are shown in figure 34-8 to figure 34-12 . figure 34-8 on page 754 shows the 24-bit single scan tft display timing; figure 34-9 on page 754 shows the 4-bit single scan stn display timing for monochrome and color modes; figure 34-10 on page 755 shows the 8-bit single scan stn display timing for monochrome and color modes; figure 34-11 on page 756
754 32054f?avr32?09/09 at32ap7002 shows the 8-bit dual scan stn display timing for monochrome and color modes; figure 34-12 on page 757 shows the 16-bit dual scan stn display timing for monochrome and color modes. figure 34-8. tft timing (first line expanded view) figure 34-9. single scan monochrome and color 4-bit panel timing (first line expanded view) lcd_vsync lcd_dval lcd_hsync lcd_pclk lcdd [24:16] lcdd [15:8] lcdd [7:0] g0 b0 r0 g1 b1 r1 lcd_vsync lcd_dval lcd_hsync lcd_pclk lcdd [3] lcdd [2] lcdd [1] lcdd [0] p1 p0 p2 p3 p5 p4 p6 p7 lcd_vsync lcd_dval lcd_h sync lcd_pclk lcdd [3] lcdd [2] lcdd [1] lcdd [0] g0 r0 b0 r1 b1 g1 r2 g2
755 32054f?avr32?09/09 at32ap7002 figure 34-10. single scan monochrome and color 8-bit panel timing (first line expanded view) lcdd [7] lcdd [6] lcdd [5] lcdd [4] p1 p0 p2 p3 p9 p8 p10 p11 lcdd [7] lcdd [6] lcdd [5] lcdd [4] g0 r0 b0 r1 r3 b2 g3 b3 lcdd [3] lcdd [2] lcdd [1] lcdd [0] p5 p4 p6 p7 p13 p12 p14 p15 lcdd [3] lcdd [2] lcdd [1] lcdd [0] b1 g1 r2 g2 g4 r4 b4 r5 lcd_vsync lcd_dval lcd_hsync lcd_pclk lcd_vsync lcd_dval lcd_hsync lcd_pclk
756 32054f?avr32?09/09 at32ap7002 figure 34-11. dual scan monochrome and color 8-bit pa nel timing (first line expanded view) lcdd [7] lcdd [6] lcdd [5] lcdd [4] lp1 lp0 l2 l3 lp5 lp4 lp6 lp7 lcdd [7] lcdd [6] lcdd [5] lcdd [4] lg0 lr0 lb0 lr1 lb1 lg1 lr2 lg2 lcdd [3] lcdd [2] lcdd [1] lcdd [0] up1 up0 up2 up3 up5 up4 up6 up7 lcdd [3] lcdd [2] lcdd [1] lcdd [0] ug0 ur0 ub0 ur1 ub1 ug1 ur2 ug2 lower pane upper pane lower pane upper pane lcd_vsync lcd_dval lcd_hsync lcd_pclk lcd_vsync lcd_dval lcd_hsync lcd_pclk
757 32054f?avr32?09/09 at32ap7002 figure 34-12. dual scan monochrome and color 16-bit panel timing (first line expanded view) lcd_vsync lcd_dval lcd_hsync lcd_pclk lcdd [15] lcdd [ 14 ] lcdd [13] lcdd [12] lp1 lp0 lp2 lp3 lp9 lp8 lp10 lp11 lcdd [15] lcdd [ 14 ] lcdd [13] lcdd [12] lg0 lr0 lb0 lr1 lr3 lb2 lg3 lb3 lcdd [11] lcdd [ 10 ] lcdd [9] lcdd [8] lp5 lp4 lp6 lp7 lp13 lp12 lp14 lp15 lcdd [11] lcdd [ 10 ] lcdd [9] lcdd [8] lb1 lg1 lr2 lg2 lg4 lr4 lb4 lr5 lcdd [7] lcdd [ 6 ] lcdd [5] lcdd [4] ug0 ur0 ub0 ur1 ur3 ub2 ug3 ub3 lcdd [3] lcdd [ 2 ] lcdd [1] lcdd [0] ub1 ug1 ur2 ug2 ug4 ur4 ub4 ur5 lower panel upper panel lc dd [7] lcdd [ 6 ] lcdd [5] lcdd [4] up1 up0 up2 up3 up9 up8 up10 up11 lcdd [3] lcdd [ 2 ] lcdd [1] lcdd [0] up5 up4 up6 up7 up13 up12 up14 up15 lower panel upper panel lcd_vsync lcd_dval lc d_hsync lcd_pclk
758 32054f?avr32?09/09 at32ap7002 table 34-12. lcd signal multiplexing lcd data bus 4-bit stn single scan (mono, color) 8-bit stn single scan (mono, color) 8-bit stn dual scan (mono, color) 16-bit stn dual scan (mono, color) 24-bit tft 16-bit tft lcdd[23] blue7 blue4 lcdd[22] blue6 blue3 lcdd[21] blue5 blue2 lcdd[20] blue4 blue1 lcdd[19] blue3 blue0 lcdd[18] blue2 intensity bit lcdd[17] blue1 lcdd[16] blue0 lcdd[15] lcdlp7 green7 green4 lcdd[14] lcdlp6 green6 green3 lcdd[13] lcdlp5 green5 green2 lcdd[12] lcdlp4 green4 green1 lcdd[11] lcdlp3 green3 green0 lcdd[10] lcdlp2 green2 intensity bit lcdd[9] lcdlp1 green1 lcdd[8] lcdlp0 green0 lcdd[7] lcd7 lcdlp3 lcdup7 red7 red4 lcdd[6] lcd6 lcdlp2 lcdup6 red6 red3 lcdd[5] lcd5 lcdlp1 lcdup5 red5 red2 lcdd[4] lcd4 lcdlp0 lcdup4 red4 red1 lcdd[3] lcd3 lcd3 lcdup3 lcdup3 red3 red0 lcdd[2] lcd2 lcd2 lcdup2 lcdup2 red2 intensity bit lcdd[1] lcd1 lcd1 lcdup1 lcdup1 red1 lcdd[0] lcd0 lcd0 lcdup0 lcdup0 red0
759 32054f?avr32?09/09 at32ap7002 34.7 interrupts the lcd controller generates six different irqs. a ll the irqs are synchronized with the internal lcdc core clock. the irqs are: ?dma memory error irq. generated when the dma receives an error response from an hsb slave while it is doing a data transfer. ?fifo underflow irq. generated when the serializer tries to read a word from the fifo when the fifo is empty. ?fifo overwrite irq. generated when the dma controller tries to write a word in the fifo while the fifo is full. ?dma end of frame irq. generated when the dma controller updates the frame base address pointers. this irq can be used to implement a double-buffer technique. for more information, see ?double-buffer technique? on page 761 . ?end of line irq. this irq is generated when the lineblank period of each line is reached and the dma controller is in inactive state. ?end of last line irq. this irq is generated when the lineblank period of the last line of the current frame is reached and the dma controller is in inactive state. each irq can be individually enabled, disabled or cleared, in the ier (interrupt enable regis- ter), idr (interrupt disable register) and icr (interrupt clear register) registers. the imr register contains the mask value for each irq source and the ldc_isr contains the status of each irq source. a more detailed description of these registers can be found in ?lcd controller (lcdc) user interface? on page 767 . 34.8 configuration sequence the dma controller starts to transfer image dat a when the lcdc core is activated (write to pwr field of pwrcon register). thus, the user should configure the lcdc core and configure and enable the dma contro ller prior to activation of the lcd controller. in addition, the image data to be shows should be available when the lcdc core is activated, regardless of the value programmed in the guard_time field of the pwrcon register. to disable the lcd controller, the user should disable the lcdc core and then disable the dma controller. the user should not enable the lcdc again until the lcdc core is in idle state. this is checked by reading t he busy bit in the pwrcon register. the initialization sequence that the user should follow to make the lcdc work is: ?create or copy the first image to show in the display buffer memory. ?if a palletized mode is used, create and store a palette in the internal lcd palette memory( see section ?34.6.2.5? on page 743. ?configure the lcd controller core without enabling it: ? lcdcon1 register: program the clkval a nd bypass fields: these fields control the pixel clock divisor that is used to generat e the pixel clock pclk. the value to program depends on the lcdc core clock and on the type and size of the lcd module used. there is a minimum value of the pclk clock period that depends on the lcd controller configuration, this minimum value can be found in table 34-11 on page 748 . the equations that are used to calculat e the value of the pixel clock divisor can be found at the end of the section ?timegen? on page 747
760 32054f?avr32?09/09 at32ap7002 ?lcdcon2 register: program its fields following their descriptions in the lcd controller user interface se ction below and considering the type of lcd module used and the desired working mode. consider that not all combinations are possible. ?lcdtim1 and lcdtim2 registers: program their fields according to the datasheet of the lcd module used and with the help of the timegen section in page 10. note that some fields are not applicable to stn modules and must be programmed with 0 values. note also that there is a limitation on the minimum value of vhdly, hpw, hbp that depends on the configuration of the lcdc. ?lcdfrmcfg register: program the di mensions of the lcd module used. ?lcdfifo register: to program it, use the formula in section ?fifo? on page 741 ?lcdmval register: its configuration depends on the lcd module used and should be tuned to improve the image quality in the display ( see section ?34.6.2.8? on page 747. ) ?dp1_2 to dp6_7 registers: they are only used for stn displays. they contain the dithering patterns used to generate gray shades or colors in these modules. they are loaded with recommended patterns at reset, so it is not necessary to write anything on them. they can be used to improve the image quality in the display by tuning the patterns in each application. ?pwrcon register: this register controls the power-up sequence of the lcd, so take care to use it properly. do not enable the lcd (writing a 1 in pwr field) until the previous steps and the configuration of the dma have been finished. ?contrast_ctr and contrast_val: use this registers to adjust the contrast of the display, when the cc line is used. ?configure the dma controller. the user should configure the base address of the display buffer memory, the size of the hsb transaction and the size of the display image in memory. when the dma is configured the user should enable the dma. to do so the user should configure the following registers: ?dmabaddr1 and dmabaddr2 registers: in single scan mode only dmabaddr1 register must be configured with the base address of the display buffer in memory. in dual scan mode dmabaddr1 should be co nfigured with the base address of the upper panel display buffer and dmabaddr2 should be configured with the base address of the lower panel display buffer. ?dmafrmcfg register: program the frmsize fi eld. note that in dual scan mode the vertical size to use in the calculation is that of each panel. respect to the brstlen field, a recommended value is a 4-word burst. ?dmacon register: once both the lcd cont roller core and the dma controller have been configured, enable the dma controller by writing a ?1? to the dmaen field of this register. if using a dual scan module or the 2d addressing feature, do not forget to write the dmaupdt bit after every change to the set of dma configuration values. ?dma2dcfg register: required only in 2d memory addressing mode (see ?2d memory addressing? on page 761 ). ?finally, enable the lcd contro ller core by writing a ?1? in the pwr field of the pwrcon register and do any other action that may be required to turn the lcd module on.
761 32054f?avr32?09/09 at32ap7002 34.9 double-buffer technique the double-buffer technique is used to avoid flickering while the frame being displayed is updated. instead of using a single buffer, there are two different buffers, the backbuffer (back- ground buffer) and the primary buffer (the buffer being displayed). the host updates the backbuffer while the lcd controller is displaying the primary buffer. when the backbuffer has been updated the host updates the dma base address registers. when using a dual panel lcd module, both base address pointers should be updated in the same frame. there are two possibilities: ?check the dmafrmptx register to ensure that there is enough time to update the dma base address registers before the end of frame. ?update the frame base address registers when the end of frame irq is generated. once the host has updated the frame base address registers and the next dma end of frame irq arrives, the backbuffer and the primary buffer are swapped and the host can work with the new backbuffer. when using a dual-panel lcd module, both ba se address pointers should be updated in the same frame. in order to achieve this, the dm aupdt bit in dmacon register must be used to validate the new base address. 34.10 2d memory addressing the lcdc can be configured to work on a frame buffer larger than the actual screen size. by changing the values in a few registers, it is easy to move the displayed area along the frame buf- fer width and height. figure 34-13. .frame buffer addressing frame buffer pixel offset line address increment ... pixel offset addr.inc
762 32054f?avr32?09/09 at32ap7002 in order to locate the displayed window within a larger frame buffer, the software must: ?program the dmabaddr1 (dmabaddr2) register (s) to make them point to the word containing the first pixel of the area of interest. ?program the pixeloff field of dma2dcfg register to specify the offset of this first pixel within the 32-bit memory word that contains it. ?define the width of the complete frame buffer by programming in the field addrinc of dma2dcfg register the address increment between the last word of a line and the first word of the next line (in number of 32-bit words). ?enable the 2d addressing mode by writing the dma2den bit in dmacon register. if this bit is not activated, the values in the dma2dcfg register are not considered and the controller assumes that the displayed area occupies a continuous portion of the memory. the above configuration can be changed frame to frame, so the displayed window can be moved rapidly. note that the frmsize field of dmafrmcfg register must be updated with any movement of the displaying window. note also that the software must write bit dmaupdt in dmacon register after each configurat ion for it to be accepted by lcdc. note: in 24 bpp packed mode, the dma base address must point to a word containing a complete pixel (possible values of pixeloff are 0 and 8). this me ans that the horizontal origin of the displaying window must be a multiple of 4 pixels or a multiple of 4 pixels minus 1 ( x = 4n or x = 4n-1 , valid ori- gins are pixel 0,3,4,7,8,11,12, etc.). 34.11 general-pur pose register the lcd controller has eight general-purpose output lines that are controlled by a general-pur- pose register (lcdgpr). the use of these lines is not fixed; they can be used in a wide range of applications. some applications examples are: ?palette swapping: in this application, the size of the palette memory is doubled. the two extra bits in the addresses (one extra bit in the low-priority address and one extra bit in the high- priority address) are connected to two general-purpose lines. one line is used to select the palette being updated through the hsb slave interface and the other line is used to select the working palette. ?common intensity control in tft mode: in this application, the most significant bit of each lcd component of the tft interface is logically or-ed with a general-purpose line. if the most significant bit of each color component in the palette is 0, the intensity can be controlled with the single general-purpose line. ?control of signals of lcd modules not included in the lcd interface, such as a standard/reverse scanning configuration pin, backlight on/off pin or user leds of the lcd module.
763 32054f?avr32?09/09 at32ap7002 34.12 register configuration examples 34.12.1 stn lcd example this example is for an stn color (rgb) 320*2 40 display, 8-bit single scan, running at 70 frames/s with a lcdc core clock of 60 mhz. fi rst, the pixel rate required to drive the display should be determined by multiplying the total number of pixels on the display (320*240) by the frame rate: pixel rate: (320*240 pixels/frame)*(70 frames/s) = 5,376,000 pixels/s next, the bit rate required to drive the displa y should be determined. since the display is stn color, each pixel consists of 3 bits (r,g,b), so the bit rate is just 3 times the pixel rate: bit rate: (5,376,000 pixels/s)*(3 bits/pixel) = 16,128,000 bits/s since the interface to the display is 8 bits wide, each pclk cycl e will transfer 8 bits to the display (neglecting front porch and back porch pclk cycles which do not transfer data). thus, the approximate pclk frequency should be dete rmined by dividing the bit rate by 8: pclk rate: (16,128,000 bits/s)/(8 bits/pclkc ycle) = 2,016,000 pclkcycles/s = 2.016 mhz now that the desired pclk rate is known, it is necessary to determine the value of the clkval field in lcd control register 1 (ldccon1) and write to this register: clkval = ((60 mhz)/(2*2.016 mhz)) - 1 = 14 (rounded to nearest integer) ldccon1 = clkval << 12; note that because clkval had to be rounded to the nearest integer, the actual pclk rate will be (60 mhz)/((14+1)*2) = 2.000 mhz. the next register that must be configured is lcd control register 2 (ldccon2). this register contains eleven fields which should be configured as follows: distype = 1; // display type: stn color scanmod = 0; // scan mode: single scan ifwidth = 1; //interface width: 8-bit pixelsize = 3; // pixel size: 8 bits per pixel invvd = 0; // lcdd polarity: normal invframe = 0; //vsync polarity: normal invline = 0; //hsync polarity: normal invclk = 0; //pclk polarity: normal invdval = 0; //dval polarity: normal clkmod = 0; //pclk mode: pclk only active during active display period for stn display memor = 2; // memory ordering format: little endian lcdcon2 can then be written as follows: ldccon2 = (memor<<30) | (c lkmod<<15) | (invdval<<12) | (invclk<<11) | (inv- line<<10) | (invframe<<9) | (invvd << 8) | (pixelsize<<5) | (ifwidth<<3) | (scanmod<<2) | (distype<<0);
764 32054f?avr32?09/09 at32ap7002 for an stn display, all bits of the lcd timing configuration register 1 must be written with 0: lcdtim1 = 0; // in stn mode, all bits must be zero lcd timing configuration register 2 contains 3 fields that control the horizontal back porch, sync pulse, and front porch width s. this example will assume that a sync pulse width of 1 pclk cycle is desired and that front and back porch widths of 11 pclk cycles are desired: hbp = 11 - 1; // horizontal back porch of 11 pclk cycles hpw = 1 - 1; // horizontal pulse width of 1 pclk cycle hfp = 11 - 1; // horizontal front porch of 11 pclk cycles lcdtim2 can then be written as follows: lcdtim2 = (hfp<<21) | (hpw<<8) | (hbp<<0); the lcd frame configuration re gister contains two fields, lineval and hozval. lineval is computed by subtracting 1 from the vertical display size (in pixels): lineval = 240 - 1; for an stn display, hozval is determined by dividi ng the horizontal display size (in bits) by the number of data lines and then subtracting one. because the stn display is color, the horizontal display size in bits is 3 times the horizontal display size in pixels: hozval= ((3*320)/8) - 1; if the value calculated for hozval is not an integer, it must be rounded up to the next integer value. lcdfrmcfg can then be written as follows: lcdfrmcfg = (hozval << 21) | (lineval<<0); the mode toggle rate value register contains two fields, mval and mmode, that determine the mode toggle rate. for this example it will be assumed that the desired mode toggle rate is 5 line periods: mval = 5 - 1; mmode = 1; // allow mval to determine the toggle rate lcdmval can then be written as follows: lcdmval = (mmode<<31) | (mval<<0); finally, the brstlen (burst length) and frmsize (frame size) fields of the dma frame con- figuration register must be determined. a desire d burst length of 8 will be assumed: brstlen = 8 - 1; the frame size is in units of 32-bit words, so it is determined by multiplying the number of pixels in the display by the number of bits used for representing a pixel in memory and then dividing by 32: frmsize = ((320*240)*8) / 32; dmafrmcfg can then be written as follows: dmafrmcfg = (brstlen <<24) | (frmsize<<0);
765 32054f?avr32?09/09 at32ap7002 34.12.2 tft lcd example this example is based on the ne c tft color lcd module nl6448bc20-08 . this module is a 640*480 display, 16-bit single scan, running at 60 frames/s. first, the pixel rate required to drive the display should be determined by multiplying the total number of pixels on the display (640*480) by the frame rate: pixel rate: (640*480 pixels/frame)*(60 frames/s) = 18,432,000 pixels/s next, the bit rate required to drive the displa y should be determined. since the display is tft color, each pixel consists of 16 bits (5 red bits, 5 green bits, 5 blue bits, and an intensity bit), so the bit rate is 16 times the pixel rate: bit rate: (18,432,000 pixels/s)*(16 bits/pixel) = 294,912,000 bits/s since the interface to the display is 16 bits wide, each pclk cycle will transfer 16 bits to the dis- play (neglecting front porch and back porch pclk cycles which do not transfer data). thus, the approximate pclk frequency should be dete rmined by dividing the bit rate by 16: pclk rate: (294,912,000 bits/s)/(16 bits/pclkc ycle) = 18,432,000 pclkcycles/s = 18.432 mhz now that the desired pclk rate is known, a nd assuming a lcdc core clock of 50 mhz, it is necessary to determin e the value of the clkval field in lcdcon1 and write to ldccon1: clkval = ((50 mhz)/(2*18.432 mhz)) - 1 = 0 (rounded to nearest integer) ldccon1 = clkval << 12; note that because it was nece ssary to round clkval to the nearest integer, the actual pclk rate will be (50 mhz)/((0+1)*2) = 25.000 mhz. the next register that must be configured is ldccon2. this register contains eleven fields which should be configured as follows: distype = 2; // display type: tft scanmod = 0; // scan mode: single scan ifwidth = 0; // interface width: 0 -- does not apply to tft displays pixelsize = 4; // pixel size: 16 bits per pixel invvd = 0; // lcdd polarity: normal invframe = 1; //vsync polarity: inverted invline = 1; //hsync polarity: inverted invclk = 1; //pclk polarity: inverted invdval = 0; //dval polarity: normal clkmod = 1; //pclk mode: pclk always active for tft displays memor = 2; // memory ordering format: little endian ldccon2 can then be written as follows: ldccon2 = (memor<<30) | (c lkmod<<15) | (invdval<<12) | (invclk<<11) | (inv- line<<10) | (invframe<<9) | (invvd << 8) | (pixelsize<<5) | (ifwidth<<3) | (scanmod<<2) | (distype<<0);
766 32054f?avr32?09/09 at32ap7002 lcdtim1 contains four fields which determine the vertical front porch, back porch, and pulse width, as well as the vertical to horizontal delay. assuming desired values for these four param- eters of 12, 31, 2, and 2, respectively, these fields should be determined as follows: vfp = (12); vbp = (31); vpw = (2 - 1); vhdly= (2 - 1); lcdtim1 can then be written as follows: lcdtim1 = (vhdly<<24) | (vpw <<16) | (vbp<<8) | (vfp<<0); lcdtim2 contains three fields which determine th e horizontal front porch, pulse width, and back porch. assuming desired values of 16, 96, and 48, respectively, these fields should be deter- mined as follows: hfp = (16 - 1); hpw= (96 - 1); hbp = (48 - 1); however, there is a problem with the calculated value of hpw (95) because the width of the hpw field in lcdtim2 is only 6 bits, which implie s that the largest allowed value of hpw is 63. fortunately, the horizontal pulse width value of 96 specified in the lcd module data sheet is just a typical value. the minimum allowed horizontal pulse width is specified as 10 in the lcd mod- ule data sheet, so hpw can be recomputed using a horizontal pulse width of 10: hpw = (10 - 1); lcdtim2 can then be written: lcdtim2 = (hfp << 21) | (hpw<<8) | (hbp<<0); the lcd frame configuration re gister contains two fields, lineval and hozval. lineval is computed by subtracting 1 from the vertical display size (in pixels): lineval = 480 - 1; for a tft display, hozval is determined by subtracting 1 from the horizontal display size: hozval = 640 - 1; lcdfrmcfg is then written as: lcdfrmcfg = (hozval<<2 1) | (lineval<<0); lcdmval determines the mode toggle rate. fo r this display, mode should toggle every frame, so all bits written to lcdmval should be zero: lcdmval = 0; // mode toggle each frame finally, the brstlen (burst length) and frmsize (frame size) fields of the dma frame con- figuration register must be determined. a desire d burst length of 8 will be assumed: brstlen = 8 - 1; the frame size is in units of 32-bit words, so it is determined by multiplying the number of pixels in the display by the number of bits used for representing a pixel in memory and then dividing by 32: frmsize = ((640*480)*16) / 32; dmafrmcfg can then be written as follows: dmafrmcfg = (brstlen<<24) | (frmsize<<0);
767 32054f?avr32?09/09 at32ap7002 34.13 lcd controller (lcdc) user interface table 34-13. lcd controller (lcdc) user interface offset register register name access reset value 0x0 dma base address register 1 dmabaddr1 r/w 0x00000000 0x4 dma base address register 2 dmabaddr2 r/w 0x00000000 0x8 dma frame pointer register 1 dmafrmpt1 read-only 0x00000000 0xc dma frame pointer register 2 dmafrmpt2 read-only 0x00000000 0x10 dma frame address register 1 dmafrmadd1 read-only 0x00000000 0x14 dma frame address register 2 dmafrmadd2 read-only 0x00000000 0x18 dma frame configuration register dmafrmcfg r/w 0x00000000 0x1c dma control register dmacon r/w 0x00000000 0x20 dma 2d addressing register dma2dcfg r/w 0x00000000 0x800 lcd control register 1 lcdcon1 r/w 0x00002000 0x804 lcd control register 2 lcdcon2 r/w 0x00000000 0x808 lcd timing register 1 lcdtim1 r/w 0x00000000 0x80c lcd timing register 2 lcdtim2 r/w 0x00000000 0x810 lcd frame configuration register lcdfrmcfg r/w 0x00000000 0x814 lcd fifo register lcdfifo r/w 0x00000000 0x818 mode toggle rate value register lcdmval r/w 0x00000000 0x81c dithering pattern dp1_2 dp1_2 r/w 0xa5 0x820 dithering pattern dp4_7 dp4_7 r/w 0x5af0fa5 0x824 dithering pattern dp3_5 dp3_5 r/w 0xa5a5f 0x828 dithering pattern dp2_3 dp2_3 r/w 0xa5f 0x82c dithering pattern dp5_7 dp5_7 r/w 0xfaf5fa5 0x830 dithering pattern dp3_4 dp3_4 r/w 0xfaf5 0x834 dithering pattern dp4_5 dp4_5 r/w 0xfaf5f 0x838 dithering pattern dp6_7 dp6_7 r/w 0xf5ffaff 0x83c power control register pwrcon r/w 0x0000000e 0x840 contrast control register contrast_ctr r/w 0x00000000 0x844 contrast value register contrast_val r/w 0x00000000 0x848 lcd interrupt enable register ier write-only 0x0 0x84c lcd interrupt disable register idr write-only 0x0 0x850 lcd interrupt mask register imr read-only 0x0 0x854 lcd interrupt status register isr read-only 0x0 0x858 lcd interrupt clear register icr write-only 0x0 0x85c lcd general-purpose register gpr r/w 0x0 0x860 lcd interrupt test register itr write-only 0 0x864 lcd interrupt raw status register irr read-only 0
768 32054f?avr32?09/09 at32ap7002 0xc00 palette entry 0 lut entry 0 r/w 0xc04 palette entry 1 lut entry 1 r/w 0xc08 palette entry 2 lut entry 2 r/w 0xc0c palette entry 3 lut entry 3 r/w ?? 0xffc palette entry 255 lut entry 255 r/w table 34-13. lcd controller (lcdc) user interface (continued) offset register register name access reset value
769 32054f?avr32?09/09 at32ap7002 34.13.1 dma base address register 1 name: dmabaddr1 access: read/write reset value: 0x00000000 ? baddr-u base address for the upper panel in dual scan mode. base address for the complete frame in single scan mode. if a dual scan configuration is selected in lcdcon2 register or bit dma2den in register dmacon is set, the bit dmaupdt in that same register must be written after writing an y new value to this field in or der to make the dma controller use this new value. note: dma base address is aligned as word address. this mean s the last two bits of this register value are always zero. 31 30 29 28 27 26 25 24 baddr-u 23 22 21 20 19 18 17 16 baddr-u 15 14 13 12 11 10 9 8 baddr-u 76543210 baddr-u
770 32054f?avr32?09/09 at32ap7002 34.13.2 dma base address register 2 name: dmabaddr2 access: read/write reset value: 0x00000000 ? baddr-l base address for the lower panel in dual scan mode only. if a dual scan configuration is selected in lcdcon2 register or bit dma2den in register dmacon is set, the bit dmaupdt in that same register must be written after writing an y new value to this field in or der to make the dma controller use this new value. note: dma base address is aligned as word address. this mean s the last two bits of this register value are always zero. 31 30 29 28 27 26 25 24 baddr-l 23 22 21 20 19 18 17 16 baddr-l 15 14 13 12 11 10 9 8 baddr-l 76543210 baddr-l
771 32054f?avr32?09/09 at32ap7002 34.13.3 dma frame pointer register 1 name: dmafrmpt1 access: read-only reset value: 0x00000000 ?frmpt-u current value of frame pointer for the upper panel in dual scan mode. current value of frame pointer for the complete frame in single scan mode. down count from frmsize to 0. note: this register is read-only and contains the current value of the frame pointer (number of wo rds to the end of the frame). it can be used as an estimation of the number of words transferred from memory for the current frame. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -frmpt-u 15 14 13 12 11 10 9 8 frmpt-u 76543210 frmpt-u
772 32054f?avr32?09/09 at32ap7002 34.13.4 dma frame pointer register 2 name: dmafrmpt2 access: read-only reset value : 0x00000000 ?frmpt-l current value of frame pointer for the lower panel in dual scan mode only. down count from frmsize to 0. note: this register is read-only and contains the current value of the frame pointer (number of wo rds to the end of the frame). it can be used as an estimation of the number of words transferred from memory for the current frame. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -- frmpt-l 15 14 13 12 11 10 9 8 frmpt-l 76543210 frmpt-l
773 32054f?avr32?09/09 at32ap7002 34.13.5 dma frame address register 1 name: dmafrmadd1 access: read-only reset value: 0x00000000 ? frmadd-u current value of frame address for the upper panel in dual scan mode. current value of frame address for the complete frame in single scan. note: this register is read-only and contains the current val ue of the last dma transaction in the bus for the panel/frame. note: dma frame address is aligned as word address. this mean s the last two bits of this register value are always zero. 31 30 29 28 27 26 25 24 frmadd-u 23 22 21 20 19 18 17 16 frmadd-u 15 14 13 12 11 10 9 8 frmadd-u 76543210 frmadd-u
774 32054f?avr32?09/09 at32ap7002 34.13.6 dma frame address register 2 name: dmafrmadd2 access: read-only reset value: 0x00000000 ? frmadd-l current value of frame address for the lower panel in dual scan mode only. note: this register is read-only and contains the current va lue of the last dma transaction in the bus for the panel. note: dma frame address is aligned as word address. this mean s the last two bits of this register value are always zero 31 30 29 28 27 26 25 24 frmadd-l 23 22 21 20 19 18 17 16 frmadd-l 15 14 13 12 11 10 9 8 frmadd-l 76543210 frmadd-l
775 32054f?avr32?09/09 at32ap7002 34.13.7 dma frame c onfiguration register name: dmafrmcfg access: read/write reset value: 0x00000000 ? frmsize: frame size in single scan mode, this is the frame size in words. in dual scan mode, this is the size of each panel. if a dual scan configuration is selected in lcdcon2 register or bit dma2den in register dmacon is set, the bit dmaupdt in that same register must be written after writing an y new value to this field in or der to make the dma controller use this new value. ? brstlen: burst length program with the desired burst length - 1 31 30 29 28 27 26 25 24 ---- brstlen 23 22 21 20 19 18 17 16 -frmsize 15 14 13 12 11 10 9 8 frmsize 76543210 frmsize
776 32054f?avr32?09/09 at32ap7002 34.13.8 dma control register name: dmacon access: read/write reset value: 0x00000000 ? dmaen: dma enable 0: dma is disabled. 1: dma is enabled. ? dmarst: dma reset (write-only) 0: no effect. 1: reset dma module. dma module should be reset only when disabled and in idle state. ? dmabusy: dma busy 0: dma module is idle. 1: dma module is busy (doing a transaction on the hsb bus). ? dmaupdt: dma configuration update 0: no effect 1: update dma configuration . used for simultaneous updating of dma parameters in dual scan mode or when using 2d addressing. the values written in the registers dmabaddr1, dmabaddr2 and dma2dcfg, and in the field frmsize of register dmafrmcfg, are accepted by the dma controller and are applied at the next frame. this bit is used only if a dual scan configuration is selected (bit scanmod of lcdcon2 register) or 2d addressing is enabled (bit dma2den in this register). otherwise, the lcd controller accepts immediately the values written in the registers referred to above. ? dma2den: dma 2d addressing enable 0: 2d addressing is disabled (values in register dma2dcfg are ?don?t care?). 1: 2d addressing is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 dma2den dmaupdt dmabusy dmarst dmaen
777 32054f?avr32?09/09 at32ap7002 34.13.9 lcd dma 2d addressing register name: dma2dcfg access: read/write reset value: 0x00000000 ? addrinc: dma 2d addressing increment when 2-d dma addressing is enabled (bit dma2den is set in register dmacon), th is field specifies the number of bytes that the dma controller must jump between screen lines. it must be programmed as: [({address of first 32-bit word in a screen line} - {address of last 32-bit word in previous line})]. in other words, it is equal to 4*[number of 32-bit words occu- pied by each line in the complete frame buffer minus the number of 32-bit words occupied by each displayed line]. bit dmaupdt in register dmacon must be writ ten after writing any new value to this field in order to make the dma control- ler use this new value. ? pixeloff: dam2d addressing pixel offset when 2d dma addressing is enabled (bit dma2den is set in register dmacon), this field specifies the offset of the first pixel in each line within th e memory word that contains this pixel. the offset is specified in number of bits in the range 0-31 , so for example a value of 4 indicates that the first pixel in th e screen starts at bit 4 of the 32-bit word pointed by register dmabaddr1. bits 0 to 3 of that word are not used. this example is valid for little end ian memory organization. when using big endian memory organization, this offset is considered from bit 31 dow nwards, or equivalently, a given value of this field always selects the pixel in the same relative position within the word, independently of the memory ordering con- figuration. bit dmaupdt in register dmacon must be written a fter writing any new value to this field in order to make the dma controller use this new value. 31 30 29 28 27 26 25 24 pixeloff 23 22 21 20 19 18 17 16 - 15 14 13 12 11 10 9 8 addrinc 76543210 addrinc
778 32054f?avr32?09/09 at32ap7002 34.13.10 lcd control register 1 name: lcdcon1 access: read/write, except linecnt: read-only reset value: 0x00002000 ? bypass: bypass pclk divider 0: the divider is not bypassed. pclk frequency defined by the clkval field. 1: the pclk divider is bypassed. pclk frequen cy is equal to the lcdc core clock frequency. ? clkval: clock divider 9-bit divider for pixel clock (pclk) frequency. ? linecnt: line counter (read-only) current value of 11-bit line counter. down count from lineval to 0. 31 30 29 28 27 26 25 24 linecnt 23 22 21 20 19 18 17 16 linecnt clkval 15 14 13 12 11 10 9 8 clkval ---- 76543210 -------bypass pixel_clock lcdc_core_clock clkval ( 1 ) + 2 () ? =
779 32054f?avr32?09/09 at32ap7002 34.13.11 lcd control register 2 name: lcdcon2 access: read/write reset value: 0x0000000 ? distype: display type ? scanmod: scan mode 0: single scan 1: dual scan ? ifwidth: interface width (stn) 31 30 29 28 27 26 25 24 memor ------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 clkmod - - invdval invclk invline invframe invvd 76543210 pixelsize ifwidth scanmod distype distype 0 0 stn monochrome 0 1 stn color 10tft 11reserved ifwidth 0 0 4-bit (only valid in single scan stn mono or color) 0 1 8-bit (only valid in stn mono or color) 1 0 16-bit (only valid in dual scan stn mono or color) 11reserved
780 32054f?avr32?09/09 at32ap7002 ? pixelsize: bits per pixel ? invvd: lcdd polarity 0: normal 1: inverted ? invframe: vsync polarity 0: normal (active high) 1: inverted (active low) ? invline: hsync polarity 0: normal (active high) 1: inverted (active low) ? invclk: pclk polarity 0: normal (lcdd fetche d at pclk falling edge) 1: inverted (lcdd fetched at pclk rising edge) ? invdval: dval polarity 0: normal (active high) 1: inverted (active low) ? clkmod: pclk mode 0: pclk only active during active display period 1: pclk always active ? memor: memory ordering format 00: big endian 10: little endian 11: wince format pixelsize 0 0 0 1 bit per pixel 0 0 1 2 bits per pixel 0 1 0 4 bits per pixel 0 1 1 8 bits per pixel 1 0 0 16 bits per pixel 1 0 1 24 bits per pixel packed (only valid in tft mode) 1 1 0 24 bits per pixel unpacked (only valid in tft mode) 1 1 1 reserved
781 32054f?avr32?09/09 at32ap7002 34.13.12 lcd timing configuration register 1 name: lcdtim1 access: read/write reset value: 0x0000000 ? vfp: vertical front porch in tft mode, these bits equal the number of idle lines at the end of the frame. in stn mode, these bits should be set to 0. ?vbp: vertical back porch in tft mode, these bits equal the number of idle lines at the beginning of the frame. in stn mode, these bits should be set to 0. ? vpw: vertical synchronization pulse width in tft mode, these bits determine the vertical synchroniz ation pulse width. vsync width is equal to (vpw+1) lines. in stn mode, these bits should be set to 0. ? vhdly: vertical to horizontal delay in tft mode, this value deter mines the delay betw een vsync rising or fa lling edge and hsync rising edge. delay is (vhdly+1) pclk cycles. in stn mode, these bits should be set to 0. 31 30 29 28 27 26 25 24 ---- vhdly 23 22 21 20 19 18 17 16 -- vpw 15 14 13 12 11 10 9 8 vbp 76543210 vfp
782 32054f?avr32?09/09 at32ap7002 34.13.13 lcd timing configuration register 2 name: lcdtim2 access: read/write reset value: 0x0000000 ? hbp: horizontal back porch determines the number of idle pclk cycles at the beginning of the line. idle period is (hbp+1) pclk cycles. ? hpw: horizontal synch ronization pulse width determines the width of the hsyn c pulse, given in pclk cycles. width is (hpw+1) pclk cycles. ? hfp: horizontal front porch determines the number of idle pclk cycles at the end of the line. idle period is (hfp+1) pclk cycles. 31 30 29 28 27 26 25 24 hfp 23 22 21 20 19 18 17 16 hfp ----- 15 14 13 12 11 10 9 8 -- hpw 76543210 hbp
783 32054f?avr32?09/09 at32ap7002 34.13.14 lcd frame configuration register name: lcdfrmcfg access: read/write reset value: 0x0000000 ? lineval: vertical size of lcd module lineval = (vertical display size) - 1 in dual scan mode, vertical display size refers to the size of each panel. ? hozval: horizontal size of lcd module in stn mode: ? hozval = (horizontal display size )/ number of valid l cdd data line) - 1 ? in stn monochrome mode, horizontal display size = number of horizontal pixels ? in stn color mode, horizontal display size = 3*number of horizontal pixels ? in 4-bit single scan or 8-bit dual scan stn display mode, number of valid lcdd data lines = 4 ? in 8-bit single scan or 16-bit dual scan stn display mode, number of valid lcdd data lines = 8 ? if the value calculated for hozval with the above formula is not an integer, it must be rounded up to the next integer value. in tft mode: ? hozval = horizontal display size - 1 31 30 29 28 27 26 25 24 hozval 23 22 21 20 19 18 17 16 hozval ----- 15 14 13 12 11 10 9 8 ----- lineval 76543210 lineval
784 32054f?avr32?09/09 at32ap7002 34.13.15 lcd fifo register name: lcdfifo access: read/write reset value: 0x0000000 ? fifoth: fifo threshold must be programmed with: where: ? lcd_fifo_size is the effective size of the fifo. it is the total fifo memory size in single scan mode and half that size in dual scan mode. ? dma_burst_length is the burst length of the transfers made by the dma. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 fifoth 76543210 fifoth fifoth lcd_fifo_size 2 dma_burst_length 3 + () ? =
785 32054f?avr32?09/09 at32ap7002 34.13.16 mode toggle rate value register name: lcdmval access: read/write reset value: 0x00000000 ? mval: mode toggle rate value mode toggle rate if mmode = 1. toggle rate is mval + 1 line periods. ? mmode: mode toggle rate select 0: each frame 1: rate defined by mval 31 30 29 28 27 26 25 24 mmode------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 mval
786 32054f?avr32?09/09 at32ap7002 34.13.17 dithering pattern dp1_2 register name: dp1_2 access: read/write reset value: 0xa5 ? dp1_2: pattern value for ? duty cycle 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 dp1_2
787 32054f?avr32?09/09 at32ap7002 34.13.18 dithering pattern dp4_7 register name: dp4_7 access: read/write reset value: 0x5af0fa5 ? dp4_7: pattern value for 4/7 duty cycle 31 30 29 28 27 26 25 24 ---- dp4_7 23 22 21 20 19 18 17 16 dp4_7 15 14 13 12 11 10 9 8 dp4_7 76543210 dp4_7
788 32054f?avr32?09/09 at32ap7002 34.13.19 dithering pattern dp3_5 register name: dp3_5 access: read/write reset value: 0xa5a5f ? dp3_5: pattern value for 3/5 duty cycle 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- dp3_5 15 14 13 12 11 10 9 8 dp3_5 76543210 dp3_5
789 32054f?avr32?09/09 at32ap7002 34.13.20 dithering pattern dp2_3 register name: dp2_3: dithering pattern dp2_3 register access: read/write reset value: 0xa5f ? dp2_3: pattern value for 2/3 duty cycle 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ---- dp2_3 76543210 dp2_3
790 32054f?avr32?09/09 at32ap7002 34.13.21 dithering pattern dp5_7 register name: dp5_7: access: read/write reset value: 0xfaf5fa5 ? dp5_7: pattern value for 5/7 duty cycle 31 30 29 28 27 26 25 24 ---- dp5_7 23 22 21 20 19 18 17 16 dp5_7 15 14 13 12 11 10 9 8 dp5_7 76543210 dp5_7
791 32054f?avr32?09/09 at32ap7002 34.13.22 dithering pattern dp3_4 register name: dp3_4 access: read/write reset value: 0xfaf5 ? dp3_4: pattern value for 3/4 duty cycle 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 dp3_4 76543210 dp3_4
792 32054f?avr32?09/09 at32ap7002 34.13.23 dithering pattern dp4_5 register name: dp4_5 access: read/write reset value: 0xfaf5f ? dp4_5: pattern value for 4/5 duty cycle 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 ---- dp4_5 15 14 13 12 11 10 9 8 dp4_5 76543210 dp4_5
793 32054f?avr32?09/09 at32ap7002 34.13.24 dithering pattern dp6_7 register name: dp6_7 access: read/write reset value: 0xf5ffaff ? dp6_7: pattern value for 6/7 duty cycle 31 30 29 28 27 26 25 24 ---- dp6_7 23 22 21 20 19 18 17 16 dp6_7 15 14 13 12 11 10 9 8 dp6_7 76543210 dp6_7
794 32054f?avr32?09/09 at32ap7002 34.13.25 power control register name: pwrcon access: read/write reset value: 0x0000000e ? pwr: lcd module power control 0 = pwr pin is low, other * pins are low. 0->1 = * pins activated, pwr are set high with the delay of guard_time frame periods. 1 = pwr pin is high, other * pins are active 1->0 = pwr pin is low, other * pins are active, but are set low after guard_time frame periods. ? guard_time delay in frame periods between applying control signals to the lcd module and setting pwr high, and between setting pwr low and removing control signals from lcd module ?busy read-only field. if 1, it indicates that the lcd is busy (act ive and displaying data, in power on sequence or in power off sequence). 31 30 29 28 27 26 25 24 busy------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 guard_time pwr
795 32054f?avr32?09/09 at32ap7002 34.13.26 contrast control register name: contrast_ctr access: read/write reset value: 0x00000000 ?ps this 2-bit value selects the configuration of a counter prescaler. the meaning of each combination is as follows: ?pol this bit defines the polarity of the output. if 1, the ou tput pulses are high level (the out put will be high whenever the value in the counter is less than the value in the compare register contrast_val). if 0, the output pulses are low level. ?ena when 1, this bit enables the operation of the pwm generator. when 0, the pwm counter is stopped. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 ----enapol ps ps 0 0 the counter advances at a rate of fcounter = flcdc_clock. 0 1 the counter advances at a rate of fcounter = flcdc_clock/2. 1 0 the counter advances at a rate of fcounter = flcdc_clock/4. 1 1 the counter advances at a rate of fcounter = flcdc_clock/8.
796 32054f?avr32?09/09 at32ap7002 34.13.27 contrast value register name: contrast_val access: read/write reset value: 0x00000000 ?cval pwm compare value. used to adjust the analog value obtained after an external filter to control the contrast of the display. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 cval
797 32054f?avr32?09/09 at32ap7002 34.13.28 lcd interrupt enable register name: ier access: write-only reset value: 0x0 ? lnie: line interrupt enable 0: no effect 1: enable each line interrupt ? lstlnie: last line interrupt enable 0: no effect 1: enable last line interrupt ? eofie: dma end of frame interrupt enable 0: no effect 1: enable end of frame interrupt ? uflwie: fifo underflow interrupt enable 0: no effect 1: enable fifo u nderflow interrupt ? owrie: fifo overwrite interrupt enable 0: no effect 1: enable fifo overwrite interrupt ? merie: dma memory error interrupt enable 0: no effect 1: enable dma memory error interrupt 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - merie owrie uflwie - eofie lstlnie lnie
798 32054f?avr32?09/09 at32ap7002 34.13.29 lcd interrupt disable register name: idr access: write-only reset value: 0x0 ? lnid: line interrupt disable 0: no effect 1: disable each line interrupt ? lstlnid: last line interrupt disable 0: no effect 1: disable last line interrupt ? eofid: dma end of frame interrupt disable 0: no effect 1: disable end of frame interrupt ? uflwid: fifo underflow interrupt disable 0: no effect 1: disable fifo un derflow interrupt ? owrid: fifo overwrite interrupt disable 0: no effect 1: disable fifo overwrite interrupt ? merid: dma memory error interrupt disable 0: no effect 1: disable dma memo ry error interrupt 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - merid owrid uflwid - eofid lstlnid lnid
799 32054f?avr32?09/09 at32ap7002 34.13.30 lcd interrupt mask register name: imr access: read-only reset value: 0x0 ? lnim: line interrupt mask 0: line interrupt disabled 1: line interrupt enabled ? lstlnim: last line interrupt mask 0: last line interrupt disabled 1: last line interrupt enabled ? eofim: dma end of frame interrupt mask 0: end of frame interrupt disabled 1: end of frame interrupt enabled ? uflwim: fifo underflow interrupt mask 0: fifo underflow interrupt disabled 1: fifo underflow interrupt enabled ? owrim: fifo overwrite interrupt mask 0: fifo overwrite interrupt disabled 1: fifo overwrite interrupt enabled ? merim: dma memory error interrupt mask 0: dma memory error interrupt disabled 1: dma memory error interrupt enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -merimowrimuflwim- eofim lstlnim lnim
800 32054f?avr32?09/09 at32ap7002 34.13.31 lcd interrupt status register name: isr access: read-only reset value: 0x0 ? lnis: line interrupt status 0: line interrupt not active 1: line interrupt active ? lstlnis: last line interrupt status 0: last line interrupt not active 1: last line interrupt active ? eofis: dma end of frame interrupt status 0: end of frame interrupt not active 1: end of frame interrupt active ? uflwis: fifo underflow interrupt status 0: fifo underflow interrupt not active 1: fifo underflow interrupt active ? owris: fifo overwrite interrupt status 0: fifo overwrite interrupt not active 1: fifo overwrite interrupt active ? meris: dma memory error interrupt status 0: dma memory error interrupt not active 1: dma memory error interrupt active 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - meris owris uflwis - eofis lstlnis lnis
801 32054f?avr32?09/09 at32ap7002 34.13.32 lcd interrupt clear register name: icr access: write-only reset value: 0x0 ? lnic: line interrupt clear 0: no effect 1: clear each line interrupt ? lstlnic: last line interrupt clear 0: no effect 1: clear last line interrupt ? eofic: dma end of frame interrupt clear 0: no effect 1: clear end of frame interrupt ? uflwic: fifo underflow interrupt clear 0: no effect 1: clear fifo underflow interrupt ? owric: fifo overwrite interrupt clear 0: no effect 1: clear fifo overwrite interrupt ? meric: dma memory error interrupt clear 0: no effect 1: clear dma memory error interrupt 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - meric owric uflwic - eofic lstlnic lnic
802 32054f?avr32?09/09 at32ap7002 34.13.33 lcd general-purpose register name: gpr access: read/write reset value: 0x0 ? gprbx: general-purpose bit controls the general-purpose line x. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 gprb7 gprb6 gprb5 gprb4 gprb3 gprb2 gprb1 gprb0
803 32054f?avr32?09/09 at32ap7002 34.13.34 lcd interrupt test register name: itr access: write-only reset value: 0x0 ? lnit: line interrupt test 0: no effect 1: set each line interrupt ? lstlnit: last line interrupt test 0: no effect 1: set last line interrupt ? eofit: dma end of frame interrupt test 0: no effect 1: set end of frame interrupt ? uflwit: fifo underflow interrupt test 0: no effect 1: set fifo underflow interrupt ? owrit: fifo overwrite interrupt test 0: no effect 1: set fifo overwrite interrupt ? merit: dma memory error interrupt test 0: no effect 1: set dma memory error interrupt 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - merit owrit uflwit - eofit lstlnit lnit
804 32054f?avr32?09/09 at32ap7002 34.13.35 lcd interrupt raw status register name: irr access: write-only reset value: 0x0 ? lnir: line interrupt raw status 0: no effect 1: line interrupt condition present ? lstlnir: last line interrupt raw status 0: no effect 1: last line interrupt condition present ? eofir: dma end of frame interrupt raw status 0: no effect 1: end of frame interrupt condition present ? uflwir: fifo underflow interrupt raw status 0: no effect 1: fifo underflow interrupt condition present ? owrir: fifo overwrite interrupt raw status 0: no effect 1: fifo overwrite interrupt condition present ? merir: dma memory error interrupt raw status 0: no effect 1: dma memory error interrupt condition present 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - merir owrir uflwir - eofir lstlnir lnir
805 32054f?avr32?09/09 at32ap7002 35. image sensor interface (isi) rev: 0.0.5.2 35.1 features ? itu-r bt. 601/656 8-bit mode external inte rface support ? supports up to 12-bit grayscale cmos sensors ? support for itu-r bt.656-4 sa v and eav synchronization ? vertical and horizontal re solutions up to 2048 x 2048 ? preview path up to 640*480 ? 128 bytes fifo on codec path ? 128 bytes fifo on preview path ? support for packed data formatting for ycbcr 4:2:2 formats ? preview scaler to genera te smaller size image ? programmable frame capture rate ? vga, qvga, cif, qcif supported for lcd preview ? custom formats with horizontal and vertical preview size as mult iples of 16 also supported for lcd preview 35.2 overview the image sensor interface (isi) connects a cmos-type image sensor to the processor and provides image capture in various formats. it does data conversion, if necessary, before the stor- age in memory through dma. the isi supports color cmos image sensor and grayscale image sensors with a reduced set of functionalities. in grayscale mode, the data stream is stored in memory without any processing and so is not compatible with th e lcd controller. internal fifos on the preview and codec paths are used to store the incoming data. the rgb output on the preview path is compatible with the lcd controller. this module outputs the data in rgb format (lcd compatible) and has scaling capabilities to make it compliant to the lcd display resolution (see table 35-3 on page 808 ). several input formats such as preprocessed rgb or ycbcr are supported through the data bus interface. it supports two modes of synchronization: 1. the hardware with vsync and hsync signals 2. the international telecommunication union recommendation itu-r bt.656-4 start-of- active-video (sav) and end-of-active-video (eav) synchronization sequence. using eav/sav for synchronization reduces th e pin count (vsync, hsync not used). the polarity of the synchronization pulse is pr ogrammable to comply with the sensor signals. table 35-1. i/o description signal dir description vsync in vertical synchronization hsync in horizontal synchronization
806 32054f?avr32?09/09 at32ap7002 figure 35-1. isi connection example 35.3 block diagram figure 35-2. image sensor interface block diagram 35.4 product dependencies 35.4.1 i/o lines the pins used for interfacing the compliant ex ternal devices may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the isi pins to their peripheral functions. data[11..0] in sensor pixel data mck out master clock provided to the image sensor pck in pixel clock provided by the image sensor table 35-1. i/o description image sensor image sensor interface data[11..0] isi_data[11..0] clk isi_mck pclk isi_pck vsync hsync isi_vsync isi_hsync timing signals interface ccir-656 embedded timing decoder(sav/eav) pixel sampling module clipping + color conversion ycc to rgb 2-d image scaler pixel formatter rx direct display fifo core video arbiter camera hsb master interface pb interface camera interrupt controller config registers clipping + color conversion rgb to ycc rx direct capture fifo scatter mode support packed formatter frame rate ycbcr 4:2:2 8:8:8 5:6:5 rgb cmos sensor pixel input up to 12 bit hsync/len vsync/fen cmos sensor pixel clock input pixel clock domain hsb clock domain pb clock domain from rx buffers camera interrupt request line codec_on hsb bus pb bus
807 32054f?avr32?09/09 at32ap7002 35.4.2 power management the isi clock is generated by the power manager. before using the isi, the programmer must ensure that the isiclock is enabled in the power manager. in the isi description, master clock (mck) is the clock of the peripheral bus to which the isi is connected. to prevent bus errors the isi operation must be terminated before entering sleep mode 35.4.3 interrupt the isi interface has an interrupt line connected to the interrupt controller. handling the isi interrupt requires programming the interrupt controller before configuring the isi. 35.5 functional description the image sensor interface (isi) supports direct connection to the international telecommuni- cation union recommendation itu-r bt. 601/656 8-bit mode compliant sensors and up to 12- bit grayscale sensors. it receives the image dat a stream from the image sensor on the 12-bit data bus. this module receives up to 12 bits for data, the ho rizontal and vertical sy nchronizations and the pixel clock. the reduced pin count alternative for synchronization is supported for sensors that embed sav (start of active vide o) and eav (end of active video) delimiters in the data stream. the image sensor interface interrupt line is gener ally connected to the interrupt controller and can trigger an interrupt at the beginning of each frame and at the end of a dma frame transfer. if the sav/eav synchronization is us ed, an interrupt ca n be triggered on each delimiter event. for 8-bit color sensors, the data stream received can be in several possible formats: ycbcr 4:2:2, rgb 8:8:8, rgb 5:6:5 and may be processed before the storage in memory. the data stream may be sent on both preview path and codec path if the bit codec_on in the cr1 is one. to optimize the bandwidth, the codec path should be enabled only when a capture is required. in grayscale mode, the input data stream is stored in memory without any processing. the 12-bit data, which represent the grayscale level for the pixel, is stored in memory one or two pixels per word, depending on the gs_mode bit in the cr2 register. the codec datapath is not available when grayscale image is selected. a frame rate counter allows users to capture all frames or 1 out of every 2 to 8 frames. 35.5.1 data timing the two data timings using hori zontal and vertical synchroni zation and eav/sav sequence syn- chronization are shown in figure 35-3 and figure 35-4 . in the vsync/hsync synchronization, the valid da ta is captured with the active edge of the pixel clock (pck), after sfd lines of vertical blanking and sld pixel cl ock periods delay pro- grammed in the control register. the itu-rbt.656-4 defines the functional timing for an 8-bit wide interface. there are two timing reference signals, one at the beginning of each video data block sav (0xff000080) and one at the end of each video data block eav(0xff00009d). only data sent between eav and sav is capt ured. horizontal blanking and vert ical blanking are ignored. use of the sav and eav synchronization eliminates t he vsync and hsync signals from the inter-
808 32054f?avr32?09/09 at32ap7002 face, thereby reducing the pin count. in order to retrieve both frame and line synchronization properly, at least one line of vertical blanking is mandatory. figure 35-3. hsync and vsync synchronization figure 35-4. sav and eav sequence synchronization 35.5.2 data ordering the rgb color space format is required for viewing images on a display screen preview, and the ycbcr color space format is required for encoding. all the sensors do not output the ycbcr or rgb components in the same order. the isi allows the user to program the same component order as the sensor, reducing software treatments to restore the right format. isi_vsync isi_hsync isi_pck frame 1 line ycby crycb y crycby cr data[7..0] isii_pck cr y cb y cr y y cr y cb ff 00 data[7..0] ff 00 00 80 y cb y 00 9d sav eav active video table 35-2. data ordering in ycbcr mode mode byte 0 byte 1 byte 2 byte 3 default cb(i) y(i) cr(i) y(i+1) mode1 cr(i) y(i) cb(i) y(i+1) mode2 y(i) cb(i) y(i+1) cr(i) mode3 y(i) cr(i) y(i+1) cb(i) table 35-3. rgb format in default mode, rgb_cfg = 00, no swap mode byte d7 d6 d5 d4 d3 d2 d1 d0
809 32054f?avr32?09/09 at32ap7002 the rgb 5:6:5 input format is processed to be displayed as rgb 5:5:5 format. the rgb 5:5:5 format is compliant with the 16-bit mode of the lcd controller. 35.5.3 clocks the sensor master clock (mck) can be generated either by the power manager through a pro- grammable clock output or by an extern al oscillator connec ted to the sensor. none of the sensors embeds a power management controller, so providing the clock by the power manager is a simple and efficient way to control power consumption of the system. care must be taken when programming the system clock. the isi has two clock domains, the system bus clock and the pixel clock provided by sensor. the two clock domains are not syn- chronized, but the system clock must be faster than pixel clock. rgb 8:8:8 byte 0 r7(i) r6(i) r5(i) r4(i) r3(i) r2(i) r1(i) r0(i) byte 1 g7(i) g6(i) g5(i) g4(i) g3(i) g2(i) g1(i) g0(i) byte 2 b7(i) b6(i) b5(i) b4 (i) b3(i) b2(i) b1(i) b0(i) byte 3 r7(i+1) r6(i+1) r5(i+1) r4(i +1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) rgb 5:6:5 byte 0 r4(i) r3(i) r2(i) r1(i) r0(i) g5(i) g4(i) g3(i) byte 1 g2(i) g1(i) g0(i) b4(i) b3(i) b2(i) b1(i) b0(i) byte 2 r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) g5(i+1) g4(i+1) g3(i+1) byte 3 g2(i+1) g1(i+1) g0(i+1) b4(i+1) b3i+1) b2(i+1) b1(i+1) b0(i+1) table 35-3. rgb format in default mode, rgb_cfg = 00, no swap table 35-4. rgb format, rgb_cfg = 10 (mode 2), no swap mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 5:6:5 byte 0 g2(i) g1(i) g0(i) r4(i) r3(i) r2(i) r1(i) r0(i) byte 1 b4(i) b3(i) b2(i) b1 (i) b0(i) g5(i) g4(i) g3(i) byte 2 g2(i+1) g1(i+1) g0(i+1) r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) byte 3 b4(i+1) b3(i+1) b2(i+1) b1(i+1) b0(i+1) g5(i+1) g4(i+1) g3(i+1) table 35-5. rgb format in default mode, rgb_cfg = 00, swap activated mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 8:8:8 byte 0 r0(i) r1(i) r2(i) r3(i) r4(i) r5(i) r6(i) r7(i) byte 1 g0(i) g1(i) g2(i) g3(i) g4(i) g5(i) g6(i) g7(i) byte 2 b0(i) b1(i) b2(i) b3 (i) b4(i) b5(i) b6(i) b7(i) byte 3 r0(i+1) r1(i+1) r2(i+1) r3(i +1) r4(i+1) r5(i+1) r6(i+1) r7(i+1) rgb 5:6:5 byte 0 g3(i) g4(i) g5(i) r0(i) r1(i) r2(i) r3(i) r4(i) byte 1 b0(i) b1(i) b2(i) b3 (i) b4(i) g0(i) g1(i) g2(i) byte 2 g3(i+1) g4(i+1) g5(i+1) r0(i+1) r1(i+1) r2(i+1) r3(i+1) r4(i+1) byte 3 b0(i+1) b1(i+1) b2(i+1) b3(i+1) b4(i+1) g0(i+1) g1(i+1) g2(i+1)
810 32054f?avr32?09/09 at32ap7002 35.5.4 preview path 35.5.4.1 scaling, deci mation (subsampling) this module resizes captured 8-bit color sensor images to fit the lcd display format. the resize module performs only downscaling. the same ra tio is applied for both horizontal and vertical resize, then a fractional decimation algorithm is applied. the decimation factor is a multiple of 1/16 and values 0 to 15 are forbidden. example: input 1280*1024 output=640*480 hratio = 1280/640 =2 vratio = 1024/480 =2.1333 the decimation factor is 2 so 32/16. table 35-6. decimation factor dec value 0->15 16 17 18 19 ... 124 125 126 127 dec factor x 1 1.063 1.125 1.188 ... 7.750 7.813 7.875 7.938 table 35-7. decimation and scaler offset values input output 352*288 640*480 800*600 1280*1024 1600*1200 2048*1536 vga 640*480 fna1620324051 qvga 320*240 f1632406480102 cif 352*288 f162633566685 qcif 176*144 f 16 53 66 113 133 170
811 32054f?avr32?09/09 at32ap7002 figure 35-5. resize examples 35.5.4.2 color space conversion this module converts ycrcb or yuv pixels to rg b color space. clipping is performed to ensure that the samples value do not exceed the allowable range. the conversion matrix is defined below: example of programmable value to convert ycrcb to rgb: an example of programmable value to convert from yuv to rgb: 1280 1024 480 640 32/16 decimation 1280 1024 288 352 56/16 decimation r g b c 0 0 c 1 c 0 c 2 ? c 3 ? c 0 c 4 0 yy off ? c b c boff ? c r c roff ? = r 1.164 y 16 ? () ? 1.596 c r 128 ? () ? + = g 1.164 y 16 ? () 0.813 c r 128 ? () ? ? 0.392 c b 128 ? () ? ? ? = b 1.164 y 16 ? () ? 2.107 c b 128 ? () ? + = ? ? ? ? ? ry 1.596 v ? + = gy 0.394 u ? ? 0.436 v ? ? = by 2.032 u ? + = ? ? ? ? ?
812 32054f?avr32?09/09 at32ap7002 35.5.4.3 memory interface preview datapath contains a data formatter that converts 8:8:8 pixel to rgb 5:5:5 format compli- ant with 16-bit format of the lcd controller. in general, when converting from a color channel with more bits to one with fewer bits, formatter module discards the lower-order bits. example: converting from rgb 8:8:8 to rgb 5:6:5, it discards the three lsbs from the red and blue chan- nels, and two lsbs from the green channel. when grayscale mode is enabled, two memory format are supported. one mode supports 2 pixels per word, and the other mode supports 1 pixel per word. 35.5.4.4 fifo and dma features both preview and codec datapaths contain fifos, asynchronous buffers that are used to safely transfer formatted pixels from pixel clock domain to high speed bus (hsb) clock domain. a video arbiter is used to manage fifo thresholds and triggers a relevant dma request through the hsb master interface. thus, depending on fifo state, a specified length burst is asserted. regarding hsb master interface, it supports scatter dma mode through linked list operation. this mode of operation improves flexibility of image buffer location and allows the user to allo- cate two or more frame buffers. the destination frame buffers are defined by a series of frame buffer descriptors (fbd). each fbd controls the transfer of one entire frame and then optionally loads a further fbd to switch the dma operation at another frame buffer address. the fbd is defined by a series of two words. the first one defines the current frame buffer address, and the second defines the next fbd memory location. this dma transfer mode is only available for pre- view datapath and is configured in the ppfbd register that indicates the memory location of the first fbd. the primary fbd is programmed into the camera interface controller. the data to be transferred described by an fbd requires several burst access. in the example below, the use of 2 ping- pong frame buffers is described. 35.5.4.5 example the first fbd, stored at address 0x30000, defines the location of the first frame buffer. destination address: frame buffer id0 0x02a000 next fbd address: 0x30010 second fbd, stored at address 0x30010, defines the location of the second frame buffer. destination address: frame buffer id1 0x3a000 transfer width: 32 bit next fbd address: 0x30000, wrapping to first fbd. using this technique, several frame buffers can be configured through the linked list. figure 35-6 illustrates a typical three frame bu ffer application. frame n is ma pped to frame buffer 0, frame n+1 is mapped to frame buffer 1, frame n+2 is mapped to frame buffer 2, further frames wrap. a codec request occurs, and the full-size 4:2:2 encoded frame is stored in a dedicated memory space. table 35-8. grayscale memory mapping configuration for 12-bit data gs_mode data[31:24] data[23:16] data[15:8] data[7:0] 0 p_0[11:4] p_0[3:0], 0000 p_1[11:4] p_1[3:0], 0000 1 p_0[11:4] p_0[3:0], 0000 0 0
813 32054f?avr32?09/09 at32ap7002 figure 35-6. three frame buffers application and memory mapping 35.5.5 codec path 35.5.5.1 color space conversion depending on user selection, this module can be bypassed so that input ycrcb stream is directly connected to the format converter module. if the rgb input stream is selected, this mod- ule converts rgb to ycrcb color sp ace with the formulas given below: an example of coefficients are given below: frame n frame n+1 frame n+2 frame n-1 frame n+3 frame n+4 frame buffer 0 frame buffer 1 frame buffer 3 4:2:2 image full roi isi config space codec request codec done lcd memory space y c r c b c 0 c 1 c 2 c 3 c ? 4 c ? 5 c ? 6 c ? 7 c 8 r g b y off cr off cb off + = y 0.257 r ? 0.504 g 0.098 b 16 + ? + ? + = c r 0.439 r ? 0.368 g ? ? 0.071 b 128 + ? ? = c b 0.148 r ? ? 0.291 g 0.439 b 128 + ? + ? ? = ? ? ? ? ?
814 32054f?avr32?09/09 at32ap7002 35.5.5.2 memory interface dedicated fifo are used to support packed memory mapping. ycrcb pixel components are sent in a single 32-bit word in a contiguous space (packed). data is stored in the order of natural scan lines. planar mode is not supported. 35.5.5.3 dma features unlike preview datapath, codec datapath dma mode does not support linked list operation. only the codec_dma_addr register is used to configure the frame buffer base address.
815 32054f?avr32?09/09 at32ap7002 35.6 image sensor interface (isi) user interface table 35-9. isi registers offset register name register access reset value 0x00 isi control 1 register cr1 read/write 0x00000002 0x04 isi control 2 register cr2 read/write 0x00000000 0x08 isi status register sr read 0x00000000 0x0c isi interrupt enable register ier write 0x00000000 0x10 isi interrupt disable register idr write 0x00000000 0x14 isi interrupt mask register imr read 0x00000000 0x18 reserved - - - 0x1c reserved - - - 0x20 isi preview size register psize read/write 0x00000000 0x24 isi preview decimation factor register pdecf read/write 0x00000010 0x28 isi preview primary fbd register ppfbd read/write 0x00000000 0x2c isi codec dma base address register cdba read/write 0x00000000 0x30 isi csc ycrcb to rgb set 0 register y2r_set0 read/write 0x6832cc95 0x34 isi csc ycrcb to rgb set 1 register y2r_set1 read/write 0x00007102 0x38 isi csc rgb to ycrcb set 0 register r2y_set0 read/write 0x01324145 0x3c isi csc rgb to ycrcb set 1 register r2y_set1 read/write 0x01245e38 0x40 isi csc rgb to ycrcb set 2 register r2y_set2 read/write 0x01384a4b 0x44-0xfc reserved ? ? ?
816 32054f?avr32?09/09 at32ap7002 35.6.1 isi control 1 register register name: cr1 access type: read/write reset value: 0x00000002 ? rst: image sensor interface reset 0: no action 1: resets the image sensor interface. ? dis: image sensor disable: 0: enable the image sensor interface. 1: finish capturing the current frame and then shut down the module. ? hsync_pol: horizontal synchronization polarity 0: hsync active high 1: hsync active low ? vsync_pol: vertical synchronization polarity 0: vsync active high 1: vsync active low ? pixclk_pol: pixel clock polarity 0: data is sampled on rising edge of pixel clock 1: data is sampled on fa lling edge of pixel clock ? emb_sync: embedded synchronization 0: synchronization by hsync, vsync 1: synchronization by embedded synchronization sequence sav/eav ? crc_sync: embedded synchronization 0: no crc correction is performed on embedded synchronization 1: crc correction is performed. if the correction is not possib le, the current frame is disc arded and the crc_err is set in the status register. ? frate: frame rate [0..7] 0: all the frames are captured, else one frame every frate+1 is captured. 31 30 29 28 27 26 25 24 sfd 23 22 21 20 19 18 17 16 sld 15 14 13 12 11 10 9 8 codec_en thmask full - frate 76543210 crc_sync emb_sync - pixclk_pol vsync_pol hsync_pol dis rst
817 32054f?avr32?09/09 at32ap7002 ? full: full mode is allowed 0: codec and preview datapaths are not working simultaneously 1: both codec and preview datapaths are working simultaneously ? thmask: threshold mask 0: 4, 8 and 16 hsb bursts are allowed 1: 8 and 16 hsb bursts are allowed 2: only 16 hsb bursts are allowed ? codec_en: enable the codec path enable bit this bit always read as zero 0: the codec path is disabled 1: the codec path is enabled and the next frame is captured ? sld: start of line delay sld pixel clock periods to wait before the beginning of a line. ? sfd: start of frame delay sfd lines are skipped at the beginning of the frame.
818 32054f?avr32?09/09 at32ap7002 35.6.2 isi control 2 register register name: cr2 access type: read/write reset value: 0x0 ? im_vsize: vertical size of the image sensor [0..2047] vertical size = im_vsize + 1 ?gs_mode 0: 2 pixels per word 1: 1 pixel per word ? rgb_mode: rgb input mode 0: rgb 8:8:8 24 bits 1: rgb 5:6:5 16 bits ? grayscale 0: grayscale mode is disabled 1: input image is assumed to be grayscale coded ?rgb_swap 0: d7 -> r7 1: d0 -> r7 the rgb_swap has no effect when the grayscale mode is enabled. ? col_space: color space for the image data 0: ycbcr 1: rgb ? im_hsize: horizontal size of the image sensor [0..2047] horizontal size = im_hsize + 1 31 30 29 28 27 26 25 24 rgb_cfg ycc_swap - im_hsize 23 22 21 20 19 18 17 16 im_hsize 15 14 13 12 11 10 9 8 col_space rgb_swap grayscale rgb_mode gs_mode im_vsize 76543210 im_vsize
819 32054f?avr32?09/09 at32ap7002 ? ycc_swap: defines the ycc image data ? rgb_cfg: defines rgb pattern when rgb_mode is set to 1 if rgb_mode is set to rgb 8:8:8, th en rgb_cfg = 0 implies rgb color sequen ce, else it implies bgr color sequence. ycc_swap byte 0 byte 1 byte 2 byte 3 00: default cb(i) y(i) cr(i) y(i+1) 01: mode1 cr(i) y(i) cb(i) y(i+1) 10: mode2 y(i) cb(i) y(i+1) cr(i) 11: mode3 y(i) cr(i) y(i+1) cb(i) rgb_cfg byte 0 byte 1 byte 2 byte 3 00: default r/g(msb) g(lsb)/b r/g(msb) g(lsb)/b 01: mode1 b/g(msb) g(lsb)/r b/g(msb) g(lsb)/r 10: mode2 g(lsb)/r b/g (msb) g(lsb)/r b/g(msb) 11: mode3 g(lsb)/b r/g(msb) g(lsb)/b r/g(msb)
820 32054f?avr32?09/09 at32ap7002 35.6.3 isi status register register name: sr access type: read reset value: 0x0 ? sof: start of frame 0: no start of frame has been detected. 1: a start of frame has been detected. ? dis: image sensor interface disable 0: the image sensor interface is enabled. 1: the image sensor in terface is disabled an d stops capturing data. the dma cont roller and the core can still read the fifos. ? softrst: software reset 0: software reset not asserted or not completed 1: software reset has completed successfully ? cdc_stat: codec request status 0: codec request has been asserted 1: codec request has been serviced ? crc_err: crc synchronization error 0: no crc error in the embedd ed synchronization frame (sav/eav) 1: the crc_sync is enabled in the control register and an error has been detected and not corrected. the frame is dis- carded and the isi waits for a new one. ? fo_c_ovf: fifo codec overflow 0: no overflow 1: an overrun condition has occurred in input fifo on the codec path. the overrun happens when the fifo is full and an attempt is made to write a new sample to the fifo. ? fo_p_ovf: fifo preview overflow 0: no overflow 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_ovf crc_err cdc_stat softrst dis sof
821 32054f?avr32?09/09 at32ap7002 1: an overrun condition has occurred in input fifo on the preview path. the overrun happens when the fifo is full and an attempt is made to write a new sample to the fifo. ? fo_p_emp 0:the dma has not finished transferring all the contents of the preview fifo. 1:the dma has finished transferring all the contents of the preview fifo. ?fo_c_emp 0: the dma has not finished transferring all the contents of the codec fifo. 1: the dma has finished transferring all the contents of the codec fifo. ? fr_ovr: frame overrun 0: no frame overrun. 1: frame overrun, the current frame is being skipped because a vsync signal has been detected while flushing fifos.
822 32054f?avr32?09/09 at32ap7002 35.6.4 interrupt enable register register name: ier access type: write reset value: 0x0 ? sof: start of frame 1: enables the start of frame interrupt. ? dis: image sensor interface disable 1: enables the dis interrupt. ? softrst: soft reset 1: enables the soft reset completion interrupt. ? crc_err: crc synchronization error 1: enables the crc_sync interrupt. ? fo_c_ovf: fifo codec overflow 1: enables the codec fifo overflow interrupt. ? fo_p_ovf: fifo preview overflow 1: enables the preview fifo overflow interrupt. ? fo_p_emp 1: enables the preview fifo empty interrupt. ?fo_c_emp 1: enables the codec fifo empty interrupt. ? fr_ovr: frame overrun 1: enables the frame overrun interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_o vf crc_err ? softrst dis sof
823 32054f?avr32?09/09 at32ap7002 35.6.5 isi interrupt disable register register name: idr access type: write reset value: 0x0 ? sof: start of frame 1: disables the start of frame interrupt. ? dis: image sensor interface disable 1: disables the dis interrupt. ?softrst 1: disables the soft reset completion interrupt. ? crc_err: crc synchronization error 1: disables the crc_sync interrupt. ? fo_c_ovf: fifo codec overflow 1: disables the codec fifo overflow interrupt. ? fo_p_ovf: fifo preview overflow 1: disables the preview fifo overflow interrupt. ? fo_p_emp 1: disables the preview fifo empty interrupt. ?fo_c_emp 1: disables the codec fifo empty interrupt. ? fr_ovr: frame overrun 1: disables frame overrun interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_o vf crc_err ? softrst dis sof
824 32054f?avr32?09/09 at32ap7002 35.6.6 isi interrupt mask register register name: imr access type: read reset value: 0x0 ? sof: start of frame 0: the start of frame interrupt is disabled. 1: the start of frame interrupt is enabled. ? dis: image sensor interface disable 0: the dis interrupt is disabled. 1: the dis interrupt is enabled. ?softrst 0: the soft reset completion interrupt is enabled. 1: the soft reset completion interrupt is disabled. ? crc_err: crc synchronization error 0: the crc_sync interrupt is disabled. 1: the crc_sync interrupt is enabled. ? fo_c_ovf: fifo codec overflow 0: the codec fifo overflow interrupt is disabled. 1: the codec fifo overflow interrupt is enabled. ? fo_p_ovf: fifo preview overflow 0: the preview fifo overflow interrupt is disabled. 1: the preview fifo overflow interrupt is enabled. ? fo_p_emp 0: the preview fifo empty interrupt is disabled. 1: the preview fifo empty interrupt is enabled. ?fo_c_emp 0: the codec fifo empty interrupt is disabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_o vf crc_err ? softrst dis sof
825 32054f?avr32?09/09 at32ap7002 1: the codec fifo empty interrupt is enabled. ? fr_ovr: frame overrun 0: the frame overrun interrupt is disabled. 1: the frame overrun interrupt is enabled.
826 32054f?avr32?09/09 at32ap7002 35.6.7 isi preview size register register name: psize access type: read/write reset value: 0x0 ? prev_vsize: vertical size for the preview path vertical preview size = prev_vsize + 1 (480 max) ? prev_hsize: horizontal size for the preview path horizontal preview size = prev_hsize + 1 (640 max) 31 30 29 28 27 26 25 24 ?????? prev_hsize 23 22 21 20 19 18 17 16 prev_hsize 15 14 13 12 11 10 9 8 ?????? prev_vsize 76543210 prev_vsize
827 32054f?avr32?09/09 at32ap7002 35.6.8 isi preview decimation factor register register name: pdecf access type: read/write reset value: 0x00000010 ? dec_factor: decimation factor dec_factor is 8-bit width, range is from 16 to 255. values from 0 to 16 do not perform any decimation. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 dec_factor
828 32054f?avr32?09/09 at32ap7002 35.6.9 isi preview primary fbd register register name: ppfbd access type: read/write reset value: 0x0 ? prev_fbd_addr: base address for preview frame buffer descriptor written with the address of the start of the preview frame buffer queue, reads as a pointer to the current buffer being used. forced to word alignement, ie the 2 lowest bits always read zero. 31 30 29 28 27 26 25 24 prev_fbd_addr 23 22 21 20 19 18 17 16 prev_fbd_addr 15 14 13 12 11 10 9 8 prev_fbd_addr 76543210 prev_fbd_addr
829 32054f?avr32?09/09 at32ap7002 35.6.10 isi codec dma base address register register name: cdba access type: read/write reset value: 0x0 ? codec_dma_addr: base address for codec dma this register contains codec datapath start address of buffer location. forced to word alignement, ie the 2 lowest bits always read zero. 31 30 29 28 27 26 25 24 codec_dma_addr 23 22 21 20 19 18 17 16 codec_dma_addr 15 14 13 12 11 10 9 8 codec_dma_addr 76543210 codec_dma_addr
830 32054f?avr32?09/09 at32ap7002 35.6.11 isi color space conversion ycrcb to rgb set 0 register register name: y2r_set0 access type: read/write reset value: 0x6832cc95 ? c3 : color space conversion matrix coefficient c3 c3 element, default step is 1/128, ranges from 0 to 255/128 ? c2 : color space conversion matrix coefficient c2 c2 element, default step is 1/128, ranges from 0 to 255/128 ? c1 : color space conversion matrix coefficient c1 c1 element, default step is 1/128, ranges from 0 to 255/128 ? c0 : color space conversion matrix coefficient c0 c0 element, default step is 1/128, ranges from 0 to 255/128 31 30 29 28 27 26 25 24 c3 23 22 21 20 19 18 17 16 c2 15 14 13 12 11 10 9 8 c1 76543210 c0
831 32054f?avr32?09/09 at32ap7002 35.6.12 isi color space conversion ycrcb to rgb set 1 register register name: y2r_set1 access type: read/write reset value: 0x00007102 ? c4: color space conversion matrix coefficient c4 c4 element default step is 1/128, ranges from 0 to 512/128 ? yoff: color space conversion luminance default offset 0: no offset 1: offset = 128 ? croff: color space conversion red chrominance default offset 0: no offset 1: offset = 16 ? cboff: color space conversion blue chrominance default offset 0: no offset 1: offset = 16 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ? cboff croff yoff ? ? ? c4 c4
832 32054f?avr32?09/09 at32ap7002 35.6.13 isi color space conversion rgb to ycrcb set 0 register register name: r2y_set0 access type: read/write reset value: 0x01324145 ? c0: color space conversion matrix coefficient c0 c0 element default step is 1/256, from 0 to 127/256 ? c1: color space conversion matrix coefficient c1 c1 element default step is 1/128, from 0 to 127/128 ? c2: color space conversion matrix coefficient c2 c2 element default step is 1/512, from 0 to 127/512 ? roff: color space conversion red component offset 0: no offset 1: offset = 16 31 30 29 28 27 26 25 24 ???????roff 23 22 21 20 19 18 17 16 -c2 15 14 13 12 11 10 9 8 -c1 76543210 -c0
833 32054f?avr32?09/09 at32ap7002 35.6.14 isi color space conversion rgb to ycrcb set 1 register register name: r2y_set1 access type: read/write reset value: 0x01245e38 ? c3: color space conversion matrix coefficient c3 c0 element default step is 1/128, ranges from 0 to 127/128 ? c4: color space conversion matrix coefficient c4 c1 element default step is 1/256, ranges from 0 to 127/256 ? c5: color space conversion matrix coefficient c5 c1 element default step is 1/512, ranges from 0 to 127/512 ? goff: color space conversion green component offset 0: no offset 1: offset = 128 31 30 29 28 27 26 25 24 ???????goff 23 22 21 20 19 18 17 16 -c5 15 14 13 12 11 10 9 8 -c4 76543210 -c3
834 32054f?avr32?09/09 at32ap7002 35.6.15 isi color space conversion rgb to ycrcb set 2 register register name: r2y_set2 access type: read/write reset value: 0x01384a4b ? c6: color space conversion matrix coefficient c6 c6 element default step is 1/512, ranges from 0 to 127/512 ? c7: color space conversion matrix coefficient c7 c7 element default step is 1/256, ranges from 0 to 127/256 ? c8: color space conversion matrix coefficient c8 c8 element default step is 1/128, ranges from 0 to 127/128 ? boff: color space conversion blue component offset 0: no offset 1: offset = 128 31 30 29 28 27 26 25 24 ???????boff 23 22 21 20 19 18 17 16 -c8 15 14 13 12 11 10 9 8 -c7 76543210 -c6
835 32054f?avr32?09/09 at32ap7002 36. on-chip debug rev: 1.0.0.0 36.1 features ? debug interface in compli ance with ieee-isto 5001- 2003 (nexus 2.0) class 3 ? jtag access to all on-chip debug functions ? advanced program, data, ownership, and watchpoint trace supported ? nanotrace jtag-based trace access ? auxiliary port for high-speed trace information ? hardware support for 6 prog ram and 2 data breakpoints ? unlimited number of softw are breakpoints supported ? automatic crc check of memory regions ? advanced program, data, ownership, and watchpoint trace supported 36.2 overview debugging on the at32ap7002 is facilitated by a powerful on -chip debug (ocd) system. the user accesses this through an external debug tool which connects to the jtag port and the aux- iliary (aux) port. the aux port is primarily used for trace functi ons, and a jtag-based debugger is sufficient for basic debugging. the debug system is based on the nexus 2.0 standard, class 3, which includes: ? basic run-time control ? program breakpoints ? data breakpoints ?program trace ? ownership trace ? data trace ? run-time direct memory access in addition to the mandatory nexus debug features, the at32ap7002 implements several useful ocd features, such as: ? debug communication channel between cpu and jtag ? run-time pc monitoring ? crc checking ? nanotrace ? software quality assurance (sqa) support the ocd features are controlled by ocd regist ers, which can be accessed by jtag when the nexus_access jtag instruction is loaded. the cpu can also access ocd registers directly using mtdr/mfdr instructions in any privileged mode. the ocd registers are implemented based on the recommendations in the nexus 2.0 standard, and are detailed in the avr32ap technical reference manual.
836 32054f?avr32?09/09 at32ap7002 36.3 block diagram figure 36-1. on-chip debug block diagram 36.4 functional description 36.4.1 jtag-based debug features a debugger can control all ocd features by writing ocd registers over the jtag interface. many of these do not depend on output on the aux port, allowing a jtag-based debugger to be used. a jtag-based debugger should connect to the device through a standard 10-pin idc connector as described in the avr32ap technical reference manual. on-chip debug jtag debug pc debug instruction cpu breakpoints program trace data trace ownership trace watchpoints transmit queue aux jtag memory nanotrace module service access bus memory interface data cache
837 32054f?avr32?09/09 at32ap7002 figure 36-2. jtag-based debugger 36.4.1.1 debug communication channel the debug communication channel (d cc) consists of a pair ocd registers with associated handshake logic, accessible to both cpu an d jtag. the registers can be used to exchange data between the cpu and the jtag master, both runtime as well as in debug mode. 36.4.1.2 breakpoints one of the most fundamental debug features is the abilit y to halt the cpu, to examine registers and the state of the system. this is accomplish ed by breakpoints, of which many types are available: ? unconditional breakpoints are set by writing ocd registers by jtag, halting the cpu immediately. ? program breakpoints halt the cpu when a specific address in the program is executed. ? data breakpoints halt the cpu when a specific memory address is read or written, allowing variables to be watched. ? software breakpoints halt the cpu when the breakpoint instruction is executed. when a breakpoint triggers, the cpu enters debug mode, and the d bit in the status register is set. this is a privileged mode with dedicated return address and return status registers. all privi- leged instructions are permitted. debug mode can be entered as either ocd mode, running instructions from jtag, or monitor mode, running instructions from program memory. avr32 jtag-based debug tool pc jtag 10-pin idc
838 32054f?avr32?09/09 at32ap7002 36.4.1.3 ocd mode when a breakpoint triggers, the cpu enters ocd mode, and instructions are fetched from the debug instruction ocd register. each time this register is written by jtag, the instruction is executed, allowing the jtag to execute cpu instructions directly. the jtag master can e.g. read out the register file by issuing mtdr instructions to the cpu, writing each register to the debug communication channel ocd registers. 36.4.1.4 monitor mode since the ocd registers are directly accessible by the cpu, it is possible to build a software- based debugger that runs on the cpu itself. setting the monitor mode bit in the development control register causes the cpu to enter monitor mode instead of ocd mode when a breakpoint triggers. monitor mode is similar to ocd mode, except that instructions are fetched from the debug exception vector in regular program memory, instead of issued by jtag. 36.4.1.5 program counter monitoring normally, the cpu would need to be halted for a jtag-based debugger to examine the current pc value. however, the at32ap7002 also proves a debug program counter ocd register, where the debugger can continuously read the current pc without affecting the cpu. this allows the debugger to generate a simple statistic of the time spent in various areas of the code, easing code optimization. 36.4.1.6 cyclic redundancy check (crc) the miu can be used to automatically calculate the crc of a block of data in memory. the ocd will then read out each word in the specified memory block and report the crc32-value in an ocd register. 36.4.1.7 nanotrace the miu additionally supports nanotrace. this is an avr32-specific feature, in which trace data is output to memory instead of the aux port. this allows the trace data to be extracted by jtag memory_access, enabling trace features for jtag-based debuggers. the user must write ocd registers to configure the address and size of the memory block to be used for nanotrace. the nanotrace buffer can be anywhere in the physical address range, including internal and external ram, through an ebi, if present. this area may not be used by the application running on the cpu. 36.4.2 aux-based debug features utilizing the auxiliary (aux) port gives a ccess to a wide range of advanced debug features. of prime importance are the trace features, which allow an external debugger to receive continuous information on the program execution in the cpu. additionally, event in and event out pins allow external events to be correlated with the program flow. the aux port contains a number of pins, as shown in table 36-1 on page 839 . these are multi- plexed with pio lines, and must explicitly be enabled by writing ocd registers before the debug session starts. the aux port is mapped to two different locations, selectable by ocd registers, minimizing the chance that the aux port will need to be shared with an application. debug tools utilizing the aux port should connec t to the device throug h a nexus-compliant mic- tor-38 connector, as described in the avr32ap technical reference manual. this connector
839 32054f?avr32?09/09 at32ap7002 includes the jtag signals and the reset_n pin, giving full access to the programming and debug features in the device. figure 36-3. aux+jtag based debugger 36.4.2.1 trace operation trace features are enabled by writing ocd registers by jtag. the ocd extracts the trace infor- mation from the cpu, compresses this information and formats it into variable-length messages according to the nexus standard. the messages are buffered in a 16-frame transmit queue, and are output on the aux port one frame at a time. the trace features can be configured to be very selective, to reduce the bandwidth on the aux port. in case the transmit queue overflows, er ror messages are produced to indicate loss of table 36-1. auxiliary port signals signal direction description mcko output trace data output clock mdo[5:0] output trace data output mseo[1:0] output trace frame control evti_n input event in evto_n output event out avr32 aux+jtag debug tool jtag aux high speed mictor38 trace buffer pc
840 32054f?avr32?09/09 at32ap7002 data. the transmit queue module can optionally be configured to halt the cpu when an overflow occurs, to prevent the loss of messages, at the expense of longer run-time for the program. 36.4.2.2 program trace program trace allows the debugger to continuously monitor the program execution in the cpu. program trace messages are generated for every branch in the program, and contains com- pressed information, which allows the debugger to correlate the message with the source code to identify the branch instruction and target address. 36.4.2.3 data trace data trace outputs a message every time a specific location is read or written. the message contains information about the type (read/write) and size of the access, as well as the address and data of the accessed location. the at32ap7002 contains two data trace channels, each of which are controlled by a pair of ocd registers which determine the range of addresses (or sin- gle address) which should produce data trace messages. 36.4.2.4 ownership trace program and data trace operate on virtual addresses. in cases where an operating system runs several processes in overlapping virtual memory segments, the ownership trace feature can be used to identify th e process switch. when the o/s activates a process, it will write the process id number to an ocd register, which produces an ownership trace message, allowing the debug- ger to switch context for the subsequent progra m and data trace messages. as the use of this feature depends on the software running on the cpu, it can also be used to extract other types of information from the system. 36.4.2.5 watchpoint messages the breakpoint modules normally used to generate program and data breakpoints can also be used to generate watchpoint messages, allowing a debugger to monitor program and data events without halting the cpu. watchpoints can be enabled independently of breakpoints, so a breakpoint module can optionally halt the cpu w hen the trigger condition occurs. data trace modules can also be configured to produce watc hpoint messages instead of regular data trace messages. 36.4.2.6 event in and event out pins the aux port also contains an event in pin (evti_n) and an event out pin (evto_n). evti_n can be used to trigger a breakpoint when an external event occurs. it can also be used to trigger specific program and data trace synchronization messages, allowing an external event to be correlated to the program flow. when the cpu enters debug mode, a debug status message is transmitted on the trace port. all trace messages can be timestamped when they are received by the debug tool. however, due to the latency of the trans mit queue buffering, the timest amp will not be 100% accurate. to improve this, evto_n can toggle every time a message is inserted into the transmit queue, allowing trace messages to be timestamped prec isely. evto_n can also toggle when a break- point module triggers, or when the cpu enters debug mode, for any reason. this can be used to measure precisely when the respective internal event occurs.
841 32054f?avr32?09/09 at32ap7002 36.4.2.7 software quality analysis (sqa) software quality analysis (sqa) deals with two important issues regarding embedded software development. code coverage involves identifying untested parts of the embedded code, to improve test procedures and thus the quality of the released software. performance analysis allows the developer to precisely quantify the time spent in various parts of the code, allowing bottlenecks to be identified and optimized. program trace must be used to accomplish these tasks without instrumenting (altering) the code to be examined. however, traditional program trace cannot reconstruct the current pc value without correlating the trace information with the source code, which cannot be done on-the-fly. this limits program trace to a relatively short time segment, determined by the size of the trace buffer in the debug tool. the ocd system in at32ap7002 extends program trace with sqa capabilities, allowing the debug tool to reconstruct the pc value on-the-f ly. code coverage and performance analysis can thus be reported for an unlimited execution sequence.
842 32054f?avr32?09/09 at32ap7002 37. jtag and boundary scan rev.: 1.0.0.0 37.1 features ? ieee1149.1 compli ant jtag interface ? boundary-scan chain for board-level testing ? direct memory access and programming capabilities through jtag interface ? on-chip debug access in compliance with ieee-isto 5001-2003 (nexus 2.0) 37.2 overview figure 37-1 on page 843 shows how the jtag is connected in an avr32 device. the tap con- troller is a state machine controlled by the tck and tms signals. the tap controller selects either the jtag instruction register or one of several data registers as the scan chain (shift register) between the tdi-input and tdo-output. the instruction register holds jtag instruc- tions controlling the behavior of a data register. the device identification register, bypass register, and the boundary-scan chain are the data registers used for board-level testing. the reset register can be used to keep the device reset during test or programming. the service access bus (sab) interface cont ains address and data registers for the service access bus, which gives access to on-chip debug, programming, and other functions in the device. the sab offers several modes of access to the addre ss and data registers, as dis- cussed in ?service access bus? on page 846 . ?jtag instruction summary? on page 848 lists the supported jtag instructions, with references to the description in this document.
843 32054f?avr32?09/09 at32ap7002 37.3 block diagram figure 37-1. jtag and boundary scan access 37.4 functional description 37.4.1 jtag interface the jtag interface is accessed through the dedicated jtag pins shown in table 37-1 on page 844 . the tms control line navigates the tap controller, as shown in figure 37-2 on page 844 . the tap controller manages the serial access to the jtag instruction and data registers. data is scanned into the selected instruction or data register on tdi, and out of the register on tdo, in the shift-ir and shift-dr states, respectively. th e lsb is shifted in and out first. tdo is high- z in other states than shift-ir and shift-dr. independent of the initial state of the tap controller, the test-logic-reset state can always be entered by holding tms high for 5 tck clock periods. this sequence should always be applied at the start of a jtag session to bring the tap controller into a defined state before applying avr32 device jtag data registers tap controller tck tms tdi tdo instruction register id register by- pass reset register memory access boundary scan chain cpu internal memory caches ocd registers external bus interface pins and analog blocks instruction register scan enable data register scan enable nexus access jtag tap trst_n boundary scan enable jtag device jtag device jtag master trst_n tck tms tdi tdo tdi tdo external memory hsb
844 32054f?avr32?09/09 at32ap7002 jtag commands. applying a 0 on tms for 1 tck period brings the tap controller to the run- test/idle state, which is the starting point for jtag operations. the device implements a 5-bit instruction regist er (ir). a number of public jtag instructions defined by the jtag standard are supported, as described in ?public jtag instructions? on page 849 , as well as a number of avr32-specific private jtag instructions described in ?private jtag instructions? on page 850 . each instruction selects a specif ic data register for the shift-dr path, as described for each instruction. figure 37-2. tap controller state diagram table 37-1. jtag pins pin direction description tck input test clock. fully asynch ronous to system clock frequency. tms input test mode select, sampled on rising tck tdi input test data in, sampled on rising tck. tdo output test data out, driven on falling tck. test-logic- reset run-test/ idle select-dr scan select-ir scan capture-dr capture-ir shift-dr shift-ir exit1-dr exit1-ir pause-dr pause-ir exit2-dr exit2-ir update-dr update-ir 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 1 0 0 0 0 0 1
845 32054f?avr32?09/09 at32ap7002 37.4.2 typical sequence assuming run-test/idle is the present state, a typical scenario for using the jtag interface is: 37.4.2.1 scanning in jtag instruction at the tms input, apply the sequence 1, 1, 0, 0 at the rising edges of tck to enter the shift instruction register - shift-ir state. while in this state, shift the 5 bits of the jtag instructions into the jtag instruction register from the tdi input at the rising edge of tck. the tms input must be held low during input of the 4 lsbs in order to remain in the shift-ir state. the jtag instruction selects a particular data register as path between tdi and tdo and controls the cir- cuitry surrounding the selected data register. apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. the instruction is latched onto the parallel output from the shift register path in the update-ir state. the exit-ir, pause-ir, and exit2-ir states are only used for navigating the state machine. figure 37-3. scanning in jtag instruction 37.4.2.2 scanning in/out data at the tms input, apply the sequence 1, 0, 0 at the rising edges of tck to enter the shift data register - shift-dr state. while in this state, upload the selected data register (selected by the present jtag instruction in the jtag instruction register) from the tdi input at the rising edge of tck. in order to remain in the shift-dr state, the tms input must be held low. while the data register is shifted in from the tdi pin, the parallel inputs to the data register captured in the capture-dr state is shifted out on the tdo pin. apply the tms sequence 1, 1, 0 to re-enter the run-test/idle state. if the selected data register has a latched parallel-output, the latching takes place in the update-dr state. the exit-dr, pause-dr, and exit2-dr states are only used for navigating the state machine. as shown in the state diagram, the run-test/idle state need not be entered between selecting jtag instruction and using data registers. 37.4.3 boundary-scan the boundary-scan chain ha s the capability of driving and obser ving the logic levels on the dig- ital i/o pins, as well as the boundary between di gital and analog logic for analog circuitry having off-chip connections. at system level, all ics having jtag capabilities ar e connected serially by the tdi/tdo signals to form a long shift register. an external controller sets up the devices to drive values at their output pins, and observe the input values received from other devices. the controller compares the received data with the expected result. in this way, boundary-scan pro- vides a mechanism for testing interconnections and integrity of components on printed circuits boards by using the 4 tap signals only. tck tap state tlr rti seldr selir capir shir ex1ir updir rti tms tdi instruction tdo impldefined
846 32054f?avr32?09/09 at32ap7002 the four ieee 1149.1 defined mandatory jtag in structions idcode, bypass, sample/pre- load, and extest can be used for testing the printed circuit board. initial scanning of the data register path will show th e id-code of the device, sinc e idcode is the default jtag instruction. it may be desirable to have the avr32 device in reset during test mode. if not reset, inputs to the device may be determined by the scan operations, and the internal software may be in an undetermined state when exiting the test mode. entering reset, the outputs of any port pin will instantly enter the high impedance st ate, making the highz instruction redundant. if needed, the bypass instruction can be issued to make the shortest possible scan chain through the device. the device can be set in t he reset state either by pulling the external resetn pin low, or issuing the avr_reset inst ruction with appropriate setting of the reset data register. the extest instruction is used for sampling external pins and loading output pins with data. the data from the output latch will be driven out on the pins as soon as the extest instruction is loaded into the jtag ir-register. therefore, the sample/preload should also be used for setting initial values to the scan ring, to avoid damaging the board when issuing the extest instruction for the first time. sample/preload c an also be used for taking a snapshot of the external pins during normal operation of the part. when using the jtag interface for boundary-sc an, the jtag tck clock is independent of the internal chip clock, whic h is not required to run. note: for pins connected to 5v lines care should be taken to not drive the pins to a logic one using boundary scan, as this will cr eate a current flowing from the 3,3v driver to the 5v pullup on the line. optionally a series resistor can be added between the line and the pin to reduce the current. 37.4.4 service access bus the avr32 architecture offers a common interface for access to on-chip debug, programming, and test functions. these are mapped on a common bus called t he service acce ss bus (sab), which is linked to the jtag port through a bus master module, which also handles synchroniza- tion between the jtag and sab clocks. when accessing the sab through the tap there are no limitatio ns on tck frequ ency compared to chip frequency, alt hough there must be an active system clock in order for the sab accesses to complete. if the system clock is switched off in sleep mode, activity on the tck pin will restart the system clock automatically, without waking the device from sleep. jtag masters may opti- mize the transfer rate by adjusting the tck frequenc y in relation to the system clock. this ratio can be measured with the sync instruction. the service access bus uses 36 address bits to address memory or registers in any of the slaves on the bus. the bus supports accesses of words (32 bits). all accesses must be aligned to the size of the access, i.e. word accesses must have the two lowest address bits cleared. a number of private inst ructions are used to access sab resour ces. each of th ese are described in detail in ?private jtag instructions? on page 850 . the memory_word_access instruc- tion allows a read or write a word to any 36-bit address on the bus. nexus_access instruction is a nexus-compliant shorthand instruction for accessing the 32-bit ocd registers in the 7-bit address space reserved for these. these instructions require two passes through the shift-dr tap state: one for the address and control information, and one for data.
847 32054f?avr32?09/09 at32ap7002 to increase the transfer rate, consecutive me mory accesses can be accomplished by the memory_block_access instruction, which only r equires a single pass through shift-dr for data transfer only. the address is automatically increment the address. the access time to sab resources depend s on the type of resource being accessed. it is possi- ble to read external memory through the ebi, in which case the latency may be very long. it is possible to abort an ongoing sab access by the cancel_a ccess instruction, to avoid hang- ing the bus due to an extremely slow slave. 37.4.4.1 busy reporting as the time taken to perform an access may vary depending on system activity and current chip frequency, all the sab access jtag instructions can return a busy indicator. this indicates whether a delay needs to be inserted, or an operation needs to be repeated in order to be suc- cessful. if a new acce ss is requested while the sab is busy, the request is ignored. the sab becomes busy when: ? entering update-dr in the address phase of any read operation, e.g. after scanning in a nexus_access address wit h the read bit set. ? entering update-dr in the data phase of any write operation, e.g. after scanning in data for a nexus_access write. ? entering update-dr during a memory_block_access. ? entering update-dr after scanning in a counter value for sync. ? entering update-ir af ter scanning in a memory_block _access if the previous access was a read and data was scanned after scanning the address. the sab becomes ready again when: ? a read or write operation completes. ? a sync countdown completed. ? a operation is cancelled by the cancel_access instruction. what to do if the busy bit is set: ? during shift-ir: the new instruction is selected, but the previous operation has not yet completed and will continue (u nless the new instruction is cancel_access). you may continue shifting the same instruction until the busy bit clears, or start shifting data. if shifting data, you must be prepared that the data shift may also report busy. ? during shift-dr of an address: the new address is ignored. the sab stays in address mode, so no data must be shifted. repeat the address until the busy bit clears. ? during shift-dr of read data: the read data are invalid. th e sab stays in data mode. repeat scanning until the busy bit clears. ? during shift-dr of write data: the write data are ignored. th e sab stays in data mode. repeat scanning until the busy bit clears. 37.4.4.2 error reporting the service access port may not be able to comp lete all accesses as requested. this may be because the address is invalid, the addressed area is read-only or cannot handle byte/halfword accesses, or because the chip is set in a protected mode where only limited accesses are allowed. the error bit is updated when an access complete s, and is cleared when a new access starts.
848 32054f?avr32?09/09 at32ap7002 what to do if the error bit is set: ? during shift-ir: the new instruction is selected. the last operation performed using the old instruction did not complete successfully. ? during shift-dr of an address: the previous operation failed. the new address is accepted. if the read bit is set, a read operation is started. ? during shift-dr of read data: the read operation failed, and the read data are invalid. ? during shift-dr of write data: the previous write operation failed. the new data are accepted and a write operation started. this should only occur during block writes or stream writes. no error can occur between scanning a write address and the following write data. ? while polling with cancel_acc ess: the previous access was ca ncelled. it may or may not have actually completed. 37.4.5 memory programming the high-speed bus (hsb) in the device is m apped as a slave on the sab. this enables all hsb-mapped memories to be read or written through the sab using jtag instructions, as described in ?service access bus? on page 846 . internal sram can always be directly accessed. external static memory or sdram can be accessed if the ebi has been correctly configured to access this memory. it is also possible to access the configuration registers for these modules to set up the correct configuration. simi- larly, external parallel flash can be programme d by accessing the registers for the flash device through the ebi. memory can be written while the cpu is ex ecuting, which can be utilized for debug purposes. when downloading a new program, the avr_reset instruction should be used to freeze the cpu, to prevent partially downloaded code from being executed. 37.5 jtag instruction summary the implemented jtag instructions in the avr32 are shown in the table below. table 37-2. jtag instruction summary instruction opcode instruction description page 0x01 idcode select the 32-bit device ident ification register as data register. 849 0x02 sample_preload take a snapshot of external pi n values without affecting system operation. 849 0x03 extest select boundary scan chain as data register for testing circuitry external to the device. 849 0x04 intest select boundary scan chain for internal testing of the device. 849 0x06 clamp bypass device through bypass register, while driving outputs from boundary scan register. 850 0x0c avr_reset apply or remove a static reset to the device 855 0x10 nexus_access select the sab address and data registers as data register for the tap. the registers are accessed in nexus mode. 851 0x11 memory_word_access select the sab address and data registers as data register for the ta p. 852
849 32054f?avr32?09/09 at32ap7002 37.6 public jtag instructions 37.6.1 idcode this instruction selects the 32 bit device identi fication register as da ta register. the device identification register consists of a version nu mber, a device number and the manufacturer code chosen by jedec. this is the default instruction after power-up. the active states are: ? capture-dr: the static idcode value is latched into the shift register. ? shift-dr: the idcode scan chain is shifted by the tck input. 37.6.2 sample_preload jtag instruction for taking a snap-shot of the input/output pins without affecting the system operation, and pre-loading the scan chain without updating the dr-latch. the boundary-scan chain is selected as data register. the active states are: ? capture-dr: data on the external pins are sampled into the boundary-scan chain. ? shift-dr: the boundary-scan chain is shifted by the tck input. extest jtag instruction for selecting the boundary-scan chain as data register for testing circuitry external to the avr32 package. the contents of the latched outputs of the boundary-scan chain is driven out as soon as the jtag ir-register is loaded with the extest instruction. the active states are: ? capture-dr: data on the external pins is sampled into the boundary-scan chain. ? shift-dr: the internal scan chain is shifted by the tck input. ? update-dr: data from the scan chain is applied to output pins. 37.6.3 intest this instruction selects the boundary-scan chain as data register for testing internal logic in the device. the logic inputs are determined by the boundary-scan chain, and the logic outputs are captured by the boundary-scan chain. the dev ice output pins are driven from the boundary- scan chain. 0x12 memory_block_access select the sab data register as data register for the tap. the address is auto-incremented. 853 0x13 cancel_access cancel an ongoing nexus or memory access. 854 0x17 sync synchronization counter 854 0x1f bypass bypass this device through the bypass register. 850 others n/a acts as bypass table 37-2. jtag instruction summary instruction opcode instruction description page
850 32054f?avr32?09/09 at32ap7002 the active states are: ? capture-dr: data from the internal logic is sampled into the boundary-scan chain. ? shift-dr: the internal scan chain is shifted by the tck input. ? update-dr: data from the scan chain is applied to internal logic inputs. 37.6.4 clamp this instruction selects the bypass register as data register. the device output pins are driven from the boundary-scan chain. the active states are: ? capture-dr: loads a logic ?0? into the bypass register. ? shift-dr: data is scanned from tdi to tdo through the bypass register. 37.6.5 bypass jtag instruction selecting the 1-bit bypass register for data register. the active states are: ? capture-dr: loads a logic ?0? into the bypass register. ? shift-dr: data is scanned from tdi to tdo through the bypass register. 37.7 private jtag instructions 37.7.1 notation the avr32 defines a number of private jtag instructions. each instruction is briefly described in text, with details fo llowing in table form. table 37-4 on page 851 shows bit patterns to be shifted in a format like " peb01 ". each character corresponds to one bit, and eight bits are groupe d together for readabilit y. the rightmost bit is always shifted first, and the leftmost bit shifted last. the symbols used are shown in table 37-3 . table 37-3. symbol description symbol description 0 constant low value - always reads as zero. 1 constant high value - always reads as one. a an address bit - always scanned with the least significant bit first b a busy bit. reads as one if the sab was busy, or zero if it was not. see ?busy reporting? on page 847 for details on how the busy reporting works. d a data bit - always scanned with the least significant bit first. e an error bit. reads as one if an error occurred, or zero if not. see ?error reporting? on page 847 for details on how the error reporting works. p the chip protected bit. some devices may be se t in a protected state where access to chip internals are severely restricted. see the docum entation for the specific device for details. on devices without this possibility, this bit always reads as zero. r a direction bit. set to one to request a read, set to zero to request a write. x a don?t care bit. any value can be shifted in, and output data should be ignored.
851 32054f?avr32?09/09 at32ap7002 in many cases, it is not required to shift all bits through the data register. bit patterns are shown using the full width of the shift register, but the suggested or required bits are emphasized using bold text. i.e. given the pattern " aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx", the shift register is 34 bits, but the test or debug unit may choose to shift only 8 bits " aaaaaaar ". the following describes how to interpret the fields in the instruction description tables: 37.7.2 nexus_access this instruction allows nexus-compliant access to on-chip debug registers through the sab. ocd registers are addressed by their register index, as listed in the avr32 technical reference manual. the 7-bit register index and a read/write control bit, and the 32-bit data is accessed through the jtag port. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in addre ss mode after the nexus_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. note : the polarity of the direction bit is inverse of the nexus standard. starting in run-test/idle, ocd registers are accessed in the following way: 1. select the dr scan path 2. scan in the 7-bit address for the ocd register and a direction bit (1=read, 0=write). 3. go to update-dr and re-enter select-dr scan 4. for a read operation, scan out the contents of the addressed register. for a write opera- tion, scan in the new contents of the register. 5. return to run-test/idle table 37-4. instruction description instruction description ir input value shows the bit pattern to shift into ir in t he shift-ir state in or der to select this instruction. the pattern is show both in binary and in hexadecimal form for convenience. example: 10000 (0x10) ir output value shows the bit pattern shifted out of ir in t he shift-ir state when this instruction is active. example: peb01 dr size shows the number of bits in the data register chain when this instruction is active. example: 34 bits dr input value shows which bit pattern to shift into the data register in the shift-dr state when this instruction is active. multiple such lines may exist, e.g. to distinguish between reads and writes. example: aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr output value shows the bit pattern shifted out of the dat a register in the sh ift-dr state when this instruction is active. multiple such lines may exist, e.g. to distinguish between reads and writes. example: xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
852 32054f?avr32?09/09 at32ap7002 for any operation, the full 7 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. 37.7.3 memory_word_access this instruction allows access to the entire service access bus data area. data are accessed through a 34-bit word index, a dire ction bit, and 32 bits of data. since word allignment is implied only the 34 most significant bits of the service access bus address is used. the data register is alternately interpreted by the sab as an address register and a data regis- ter. the sab starts in address mode after the memory_word_access instruction is selected, and toggles between address and data mode each time a data scan completes with the busy bit cleared. starting in run-test/idle, sab dat a are accessed in the following way: 1. select the dr scan path 2. scan in the 34-bit address of the data to access, and a direction bit (1=read, 0=write). 3. go to update-dr and re-enter select-dr scan 4. for a read operation, scan out the contents of the addressed area. for a write operation, scan in the new contents of the area. 5. return to run-test/idle for any operation, the full 34 bits of the address must be provided. for write operations, 32 data bits must be provided, or the result will be undefined. for read ope rations, shifting may be termi- nated once the required number of bits have been acquired. table 37-5. nexus_access details instructions details ir input value 10000 (0x10) ir output value peb01 dr size 34 bits dr input value (address phase) aaaaaaar xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (address phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 37-6. memory_word_access details instructions details ir input value 10001 (0x11) ir output value peb01 dr size 35 bits dr input value (address phase) aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa aar dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xxx
853 32054f?avr32?09/09 at32ap7002 37.7.4 memory_block_access this instruction allows access to the entire sab data area. up to 32 bits of data are accessed at a time, while the address is sequentially in cremented from the previously used address. in this mode, the sab add ress, and access direction is not provided with each access. instead, the previous address is auto-incremented and the previous operation repeated. the address must be set up in advance with memory_word_access. it is allowed, but not required, to shift data after shifting the address. this instruction is primarily intended to speed up large quantities of sequential word accesses.. the following sequence should be used: 1. use the memory_word_access to re ad or write the first location. 2. apply memory_block_access in the ir scan path. 3. select the dr scan path. th e address will now have incremen ted by 4 (corre sponding to the next word location). 4. for a read operation, scan out the contents of the next addressed location. for a write operation, scan in the new contents of the next addressed location. 5. go to update-dr 6. if the block access is not complete, return to select-dr scan and repeat the access. 7. if the block access is complete, return to run-test/idle for write operations, 32 data bits must be pr ovided, or the result will be undefined. for read operations, shifting may be terminated once the required number of bits have been acquired. the overhead using block word access is 4 cycles per 32 bits of data, resulting in an 88% trans- fer efficiency, or 2.1 mbytes per second with a 20 mhz tck frequency. dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xxx dr output value (address phase) xxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx dr output value (data read phase) xeb dddddddd dddddddd dddddddd dddddddd dr output value (d ata write phase) xxx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb table 37-6. memory_word_access details (continued) instructions details table 37-7. memory_block_access details instructions details ir input value 10010 (0x12) ir output value peb01 dr size 34 bits dr input value (data read phase) xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xx dr input value (data write phase) dddddddd dddddddd dddddddd dddddddd xx dr output value (data read phase) eb dddddddd dddddddd dddddddd dddddddd dr output value (data write phase) xx xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxeb
854 32054f?avr32?09/09 at32ap7002 37.7.5 cancel_access if a very slow memory location is accessed du ring a sab memory access, it could take a very long time until the busy bit is cleared, and the sab becomes ready for the next operation. the cancel_access instruction pr ovides a possibility to abort an ongoing transfer and report a timeout to the user. when the cancel_access instruction is select ed, the current access will be terminated as soon as possible. there are no guarantees about how long this will take, as the hardware may not always be able to cancel the access immedi ately. the sab is ready to respond to a new command when the busy bit clears. 37.7.6 sync this instruction allows external debuggers and testers to measure the ratio between the external jtag clock and the internal system clock. the sync data register is a 16-bit counter that counts down to zero using the internal system clock. the busy bit stays high until the counter reaches zero. starting in run-test/idle, sync inst ruction is used in the following way: 1. select the dr scan path 2. scan in an 16-bit counter value 3. go to update-dr and re-enter select-dr scan 4. scan out the busy bit, and retry until the busy bit clears. 5. calculate an approximation to the internal clock speed using the elapsed time and the counter value. 6. return to run-test/idle the full 16-bit counter value must be provided when starting the synch operation, or the result will be undefined. when r eading status, shifting may be term inated once the required number of bits have been acquired. table 37-8. cancel_access details instructions details ir input value 10011 (0x13) ir output value peb01 dr size 1 dr input value x dr output value 0 table 37-9. sync_access details instructions details ir input value 10111 (0x17) ir output value peb01 dr size 16 bits dr input value dddddddd dddddddd dr output value xxxxxxxx xxxxxxeb
855 32054f?avr32?09/09 at32ap7002 37.7.7 avr_reset this instruction allows a debugger or tester to directly control separate reset domains inside the chip. the shift register contains one bit for each controllable reset domain. setting a bit to one resets that domain and holds it in reset. setting a bit to zero releases the reset for that domain. see the device specific document ation for the number of reset domains, and what these domains are. for any operation, all bits must be provided or th e result will be undefined. table 37-10. avr_reset details instructions details ir input value 01100 (0x0c) ir output value p0001 dr size device specific . typically 5 bits. dr input value ddddd dr output value ddddd
856 32054f?avr32?09/09 at32ap7002 37.8 jtag data registers the following device specific registers can be selected as jtag scan chain depending on the instruction loaded in the jtag instruction register. additional registers exist, but are implicitly described in the functional description of the relevant instructions. 37.8.1 device identification register the device identification register contains a unique identifier for each product. the register is selected by the idcode instruction, which is the default instruction after a jtag reset. 37.8.1.1 device specific id codes the different device configurations have di fferent jtag id codes, as shown in table 37-11 . . 37.8.2 reset register the reset register is selected by the avr_reset instruction and co ntains one bit for each reset domain in the device. se tting each bit to one will keep that domain reset until the bit is cleared. ms b lsb bit 31 28 27 12 11 1 0 device id revision part number manufacturer id 1 4 bits 16 bits 11 bits 1 bit revision this is a 4 bit number identifying the revision of the component. rev a = 0x0, b = 0x1, etc. part number the part number is a 16 bit code identifying the component. manufacturer id the manufacturer id is a 11 bit code identifying the manufacturer. the jtag manufacturer id for atmel is 0x01f. table 37-11. device and jtag id device name jtag id code (r is the revision number) at32ap7000 0xr1e8203f at32ap7002 0xr1e8203f lsb bit 43210 device id ocd app dcache icache cpu cpu cpu icache instruction cache
857 32054f?avr32?09/09 at32ap7002 this register is intended to be used when prog ramming the device, to avoid running partially downloaded code. the following procedure is recommended: ? reset = ocd | app | dcache | icache | cpu ? this will bring the entire system back to its reset state, re gardless of the preceding state. ? reset = icache | cpu ? this keeps the icache and cpu from fetching and executing partially downloaded instructions. ? perform the programming operations ? reset = 0 ? the cpu will start executing from the reset vector. it is not recommended to use the reset register for other purposes than described above, as operations may not function correctly when parts of the system are reset. 37.8.3 boundary-scan chain the boundary-scan chain has the ca pability of driving an d observing the logic levels on the dig- ital i/o pins, as well as driving and observing the logic levels between the digital i/o pins and the internal logic. typically, output value, output enable, and input data are all available in the boundary scan chain. the boundary scan chain is described in the bdsl (boundary scan description language) file available at the atmel web site. 37.9 sab address map the service access bus (sab) gives the user access to the internal address space and other features through a 36 bits address space. the 4 msbs identify the slave number, while the 32 lsbs are decoded within the slave?s addres s space. the sab slaves are shown in table 37-12 . dcache data cache and jtag sab interface app hsb and pb buses ocd on-chip debug logic and registers table 37-12. sab slaves, addresses and descriptions. slave address [35:32] description unallocated 0x0 intentionally unallocated ocd 0x1 ocd registers hsb cached 0x4 hsb memory space, as seen by the cpu through the data cache hsb uncached 0x5 alternative mapping for hsb space, as seen by the cpu bypassingthe data cache. reserved other unused
858 32054f?avr32?09/09 at32ap7002 38. boot sequence this chapter summarizes the boot sequence of the at32ap7002. the behaviour after power-up is controlled by the power manager. 38.1 starting of clocks after power-up, the device will be held in a rese t state by the power-on reset (por) circuitry until the voltage has reached the power-on reset ri sing threshold value (see electrical character- istics for details). this ensure s that all critical parts of the device are properly reset. once the power-on reset is comp lete, the device will use the xin0 pin as clock source. xin0 can be connected either to an external clock, or a crystal. the oscen_n pin is connected either to vdd or gnd to inform the power manager on how the xin0 pin is connected. if xin0 receives a signal from a crystal, dedicated circuitry in the power manager keeps the part in a reset state until the oscillator connected to xin0 has settled. if xin0 receives an external clock, no such set- tling delay is applied. on system start-up, the plls are disabled. all clocks to all modules are running. no clocks have a divided frequency, all parts of the system recieves a clock with the same frequency as the xin0 clock. note that the power-on reset will release reset at a lower voltage threshold than the minimum specified operating voltage. if the voltage is not guaranteed to be stable by the time the device starts executing, an external brown-out reset circuit should be used. 38.2 fetching of initial instructions after reset has been released, the avr32ap cpu starts fetching instructions from the reset address, which is 0xa000_0000. this address lies in the p2 segment, which is non-translated, non-cacheable, and permanently mapped to the physical address range 0x0000_0000 to 0x2000_0000. this means that the instruction being fetched from virtual address 0xa000_0000 is being fetched from physical address 0x0000_0000. physical address 0x0000_0000 is mapped to ebi sram cs0. this is the external memory the device boots from. the code read from the sram cs0 memory is free to configure the system to use for example the plls, to divide the frequency of the clock routed to some of the peripherals, and to gate the clocks to unused peripherals.
859 32054f?avr32?09/09 at32ap7002 39. mechanical characteristics 39.1 avr32ap7002 39.1.1 thermal considerations 39.1.1.1 thermal data table 39-1 summarizes the thermal resistance data depending on the package. 39.1.1.2 junction temperature the average chip-junction temperature, t j , in c can be obtained from the following: 1. 2. where: ? ja = package thermal resistance, junction-to-ambient (c/w), provided in table 39-4 on page 861 . ? jc = package thermal resistance, junction-to-case thermal resistance (c/w), provided in table 39-4 on page 861 . ? heat sink = cooling device thermal resistance (c/w), provided in the device datasheet. ?p d = device power consumption (w) estimated from data provided in the power consumption section, in the next chapter. ?t a = ambient temperature (c). from the first equation, the user can derive the estimated lifetime of the chip and decide if a cooling device is necessary or not. if a coolin g device is to be fitted on the chip, the second equation should be used to compute the resulting average chip-junction temperature t j in c. table 39-1. thermal resistance data symbol parameter condition package typ unit ja junction-to-ambient thermal resistance still air ctbga196 39.2 c/w jc junction-to-case thermal resistance ctbga196 10.3 t j t a p d ja () + = t j t a p ( d ( heatsink jc )) ++ =
860 32054f?avr32?09/09 at32ap7002 39.1.2 package drawings figure 39-1. 196-balls ctbga package drawing - tbd
861 32054f?avr32?09/09 at32ap7002 39.1.3 soldering profile table 39-6 gives the recommended soldering profile from j-std-20. note: it is recommended to apply a soldering temperature higher than 250c. a maximum of three reflow passes is allowed per component. table 39-2. soldering information ball land 0.48 solder mask opening 0.38 table 39-3. device and 196-ball ctbga package maximum weight 350 mg table 39-4. 196-ball ctbga package characteristics moisture sensitivity level 3 table 39-5. package reference jedec drawing reference mo-216 jesd97 classification e1 table 39-6. soldering profile profile feature green package average ramp-up rate (217c to peak) 3c/sec preheat temperature 175c 25c 60 - 180 sec temperature maintained above 217c 60 - 150 sec time within 5 c of actual peak temperature 20 - 40 sec peak temperature range 260 + 0c ramp-down rate 6c/sec max time 25 c to peak temperature 8 minuts max
862 32054f?avr32?09/09 at32ap7002 40. electrical characteristics 40.1 absolute maximum ratings 40.2 dc characteristics the following characteristics are applicable to the operating temperature range: t a = -40c to 85c, unless otherwise spec- ified and are certified for a junction temperature up to t j = 100c. table 40-1. absolute maximum ratings* operating temperature (industrial)............ -40 c to +85 c *notice: stresses beyond those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational se ctions of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reli- ability. storage temperature ............................... -60c to +150c voltage on input pins with respect to ground-0.3v to vddio + 0.3v (+3.9v max) maximum operating voltage (vddcore, vddosc, vddpll and vddusb) ..... 1.95v maximum operating voltage (vddio ) ..................................................................... 3.6v total dc output current on all i/o lines ................ 350 ma table 40-2. dc characteristics symbol parameter conditions min typ max units v vddcore dc supply core 1.65 1.95 v v vddbu dc supply backup 1.65 1.95 v vddosc dc supply oscillator 1.65 1.95 v v vddpll dc supply pll 1.65 1.95 v v vddusb dc supply usb 1.65 1.95 v v vddio dc supply peripheral i/os 3.0 3.6 v v il input low-level voltage -0.3 +0.8 v v ih input high-level voltage 2.0 v vddio +0.3 v v ol output low-level voltage i ol = 8 ma 0.4 v i ol, tdo = 2 ma v oh output high-level voltage i oh = 8 ma v vddio -0.4 v i oh, tdo = 2 ma i il input leakage current, pin low pullup resistors disabled 1 a i ih input leakage current, pin high pullup resistors disabled 1 a r pulluppio pull-up resistance on pio pins 190 k
863 32054f?avr32?09/09 at32ap7002 note: 1. includes the tck, tms, tdi, oscen_ n, trst_n, reset_n, evt i_n, and wake_n pins. 40.3 power consumption ?typical power consumption of plls , slow clock and main oscillator. ?power consumption of power supply in active mode. ?power consumption by peripheral: calculated as the difference in current measurement after having enabled then disabled the corresponding clock. 40.3.1 power consumption versus modes the values in table 40-3 and table 40-4 on page 864 are measured values of power consump- tion with operating conditions as follows: ?v vddio = 3.3v ?v vddcore = v vddusb = v vddpll = v vddosc = 1.8v ?t a = 25 c ?there is no consumption on the i/os of the device figure 40-1. measures schematics r pullupctrl pull-up resistance on control and jtag pins (1) 13 k i o output current 8 ma i o, tdo output current, tdo pin 2 i sc static current on v vddcore = 1.8v, cpu = 0 hz t a =25c 300 a all inputs driven; reset_n=1 t a =85c 5000 table 40-2. dc characteristics (continued) vddcore vddusb vddpll vddosc amp
864 32054f?avr32?09/09 at32ap7002 these figures represent the power consum ption measured on the power supplies. note: 1. the value is measured at best case conditi on. actual current consumption will vary depending on the application. . note: 1. these numbers are relative to the actual cpu clock frequency, using the standard bus divi- sion: hsb and pbb divided by two. pba divided by four. table 40-3. typical power consumption for different operating modes mode conditions typical consumption unit active (1) all peripheral clocks deactivated. 500 a/mhz idle all peripheral clocks activated. 480 frozen all peripheral clocks activated. 280 standby all peripheral clocks activated. 80 table 40-4. power consumption by peripheral in active mode peripheral consumption unit (1) pio controller 3 a/mhz usart 3 usb 9 smc 1 sdramc 1 ac97 5 isi 3 audio dac 1 lcdc 31 twi 1 spi 1 mci 7 ssc 3 timer counter channels 1
865 32054f?avr32?09/09 at32ap7002 40.4 clock characteristics these parameters are given in the following conditions: v vddcore = 1.8v, ambient temperature = 25c, unless otherwise specified. 40.4.1 cpu clock characteristics note: 1. the bus clocks in the system should be divided, relative to the cpu, to be sure they operate in their specified range. t he hsb and pbb bus clocks should be divided by two and the pba bus clock should be divided by four relative to the cpu clock. the division factor of the buses can be set by programming the power manager register cksel. figure 40-2 and figure 40-3 shows typical maximum cpu frequencies based on a selection of samples from different lots. figure 40-2. cpu clock frequency vs. v vddcore (typical) table 40-5. guaranteed cpu clock frequencies. symbol parameter conditions min max units 1/(t cpcpu ) cpu clock frequency (1) te m p = 8 5 c, v vddcore = 1.8v 150 mhz 1/(t cpcpu ) cpu clock frequency (1) te m p = 8 5 c, v vddcore = 1.65v 133 mhz 8 5 c 25 c -40 c 100 120 140 160 1 8 0 200 220 240 1.6 1.65 1.7 1.75 1. 8 1. 8 5 1.9 1.95 2 v v ddcore ( v ) fre qu ency (mhz)
866 32054f?avr32?09/09 at32ap7002 figure 40-3. cpu clock frequency vs. temperature (typical) 40.4.2 xin clock characteristics note: 1. these characteristics apply only when the osc illators arein bypass mode (i.e., when oscen_n is 1) 40.4.3 reset_n characteristics 1.95 v 1.90 v 1. 8 5 v 1. 8 0 v 1.75 v 1.70 v 1.65 v 100 120 140 160 1 8 0 200 220 240 -60 -40 -20 0 20 40 60 8 0100 temperat u re (c) fre qu ency (mhz) table 40-6. xin clock electrical characteristics symbol parameter conditions min max units 1/(t cpxin ) xin clock frequency (1 50.0 mhz table 40-7. reset_n electrical characteristics symbol parameter conditions min max units t reset reset_n minimum pulse length 50 ns
867 32054f?avr32?09/09 at32ap7002 40.5 crystal oscillat or characteristics the following characteristics are applicabl e to the operating temperature range: t a = -40c to 85c and worst case of power supply, unless otherwise specified. 40.5.1 32 khz oscillator characteristics note: 1. r s is the equivalent series resistance, c l is the equivalent load capacitance. 40.5.2 main oscillators characteristics notes: 1. c s is the shunt capacitance 40.5.3 pll characteristics note: 1. startup time depends on pll rc filter. a calculation tool is provided by atmel. table 40-8. 32 khz oscillator characteristics symbol parameter conditions min typ max unit 1/(t cp32khz ) crystal oscillator frequency 32 768 hz t st startup time v ddosc = 1.8 v r s = tbd k , c l = tbd pf (1) 1000 ms table 40-9. main oscillator characteristics symbol parameter conditions min typ max unit 1/(t cpmain ) crystal oscillator frequency 10 27 mhz c l1 , c l2 internal load capacitance (c l1 = c l2 ) tbd pf t st startup time 4ms table 40-10. phase lock loop characteristics symbol parameter conditions min typ max unit f out output frequency 80 150 mhz f in input frequency 6 32 mhz
868 32054f?avr32?09/09 at32ap7002 40.6 usb transceiver characteristics 40.6.1 electrical characteristics 40.6.2 switching characteristics table 40-11. electrical parameters symbol parameter conditions min typ max unit input levels v il low level 0.8 v v ih high level 2.0 v v di differential input sensivity |(d+) - (d-)| 0.2 v v cm differential input common mode range 0.8 2.5 v c in transceiver capacitance capacitance to ground on each line 75 pf i hi-z state data line leakage 0v < v in < 3.3v tbd tbd a r ext recommended external usb series resistor in series with each usb pin with 5% 39 output levels v ol low level output measured with r l of 1.425 k tied to 3.6v 00.3v v oh high level output measured with r l of 14.25 k tied to gnd 2.8 3.6 v v crs output signal crossover voltage measure conditions described in figure 40-4 1.3 2.0 v table 40-12. in full speed symbol parameter conditions min typ max unit t fr transition rise time c load = 50 pf 4 20 ns t fe transition fall time c load = 50 pf 4 20 ns t frfm rise/fall time matching 90 111 % table 40-13. in high speed symbol parameter conditions min typ max unit t fr tr a n s i t i o n r i s e t i m e specified with test fixture + usb cable 500 tbd ps t fe transition fall time 500 tbd ps
869 32054f?avr32?09/09 at32ap7002 figure 40-4. usb data signal rise and fall times 10% 10% 90% v crs t r t f differential data lines rise time fall time fosc = 6 mhz/750khz r ext = 39 ohms c load buffer (b) (a)
870 32054f?avr32?09/09 at32ap7002 40.7 ac characteristics 40.8 ebi timings these timings are given for worst case process, t = 85 c, vddcore = 1.65v, vddio = 3v and 50 pf load capacitance. note: 1. the maximum frequenzy of the smc interfac e is the same as the max frequnzy for the hsb. note: 1. hold length = total cycle duration - setup duration - pulse duration. ?hold length? is for ?ncs rd hold length? or ?nrd hold length?. table 40-14. smc clock signal. symbol parameter max (1) units 1/(t cpsmc ) smc controller clock frequency 1/(2t cpcpu )mhz table 40-15. smc read signals with hold settings symbol parameter min units nrd controlled (read_mode = 1) smc 1 data setup before nrd high 11.2 ns smc 2 data hold after nrd high 0 smc 3 nrd high to nbs0/a0 change (1) nrd hold length * t cpsmc - 1.3 smc 4 nrd high to nbs1 change (1) nrd hold length * t cpsmc - 1.3 smc 5 nrd high to nbs2/a1 change (1) nrd hold length * t cpsmc - 1.3 smc 6 nrd high to nbs3 change (1) nrd hold length * t cpsmc - 1.3 smc 7 nrd high to a2 - a25 change (1) nrd hold length * t cpsmc - 1.3 smc 8 nrd high to ncs inactive (1) (nrd hold length - ncs rd hold length) * t cpsmc - 0.6 smc 9 nrd pulse width nrd pulse length * t cpsmc - 0.1 nrd controlled (read_mode = 0) smc 10 data setup before ncs high 12.4 ns smc 11 data hold after ncs high 0 smc 12 ncs high to nbs0/a0 change (1) ncs rd hold length * t cpsmc - 2.5 smc 13 ncs high to nbs0/a0 change (1) ncs rd hold length * t cpsmc - 2.5 smc 14 ncs high to nbs2/a1 change (1) ncs rd hold length * t cpsmc - 2.5 smc 15 ncs high to nbs3 change (1) ncs rd hold length * t cpsmc - 2.5 smc 16 ncs high to a2 - a25 change (1) ncs rd hold length * t cpsmc - 1.2 smc 17 ncs high to nrd inactive (1) ncs rd hold length - nrd hold length)* t cpsmc - 4.3 smc 18 ncs pulse width ncs rd pulse length * t cpsmc - 1.5
871 32054f?avr32?09/09 at32ap7002 note: 1. hold length = total cycle duration - setup duration - pulse duration. ?hold length? is for ?ncs wr hold length? or ?nwe hold length" table 40-16. smc read signals with no hold settings symbol parameter min units nrd controlled (read_mode = 1) smc 19 data setup before nrd high 15.8 ns smc 20 data hold after nrd high 0 nrd controlled (read_mode = 0) smc 21 data setup before ncs high 17.0 ns smc 22 data hold after ncs high 0 table 40-17. smc write signals with hold settings symbol parameter min units nrd controlled (read_mode = 1) smc 23 data out valid before nwe high (nwe pulse length - 1) * t cpsmc - 1.6 ns smc 24 data out valid after nwe high (1) nwe hold length * t cpsmc - 1.5 smc 25 nwe high to nbs0/a0 change (1) nwe hold length * t cpsmc - 1.0 smc 26 nwe high to nbs1 change (1) nwe hold length * t cpsmc - 1.0 smc 29 nwe high to nbs2/a1 change (1) nwe hold length * t cpsmc - 1.0 smc 30 nwe high to nbs3 change (1) nwe hold length * t cpsmc - 1.0 smc 31 nwe high to a2 - a25 change (1) nwe hold length * t cpsmc - 1.6 smc 32 nwe high to ncs inactive (1) (nwe hold length - n cs wr hold length)* t cpsmc - 0.3 smc 33 nwe pulse width nwe pulse length * t cpsmc nrd controlled (read_mode = 0) smc 34 data out valid before ncs high (ncs wr pulse length - 1)* t cpsmc - 1.9 ns smc 35 data out valid after ncs high (1) ncs wr hold length * t cpsmc - 3.0 smc 36 ncs high to nwe inactive (1) (ncs wr hold length - nwe hold length)* t cpsmc - 1.5
872 32054f?avr32?09/09 at32ap7002 figure 40-5. smc signals for ncs controlled accesses. table 40-18. smc write signals with no hold settings (nwe controlled only). symbol parameter min units smc 37 nwe rising to a2-a25 valid 8.0 ns smc 38 nwe rising to nbs0/a0 valid 8.0 smc 39 nwe rising to nbs1 change 8.0 smc 40 nwe rising to a1/nbs2 change 8.0 smc 41 nwe rising to nbs3 change 8.0 smc 42 nwe rising to ncs rising 8.5 smc 43 data out valid before nwe risi ng (nwe pulse length - 1) * t cpsmc - 4.9 smc 44 data out valid after nwe rising 8.4 smc 45 nwe pulse width nwe pulse length * t cpsmc + 0.3 nrd nc s d0 - d15 nwe a2-a25 a0/a1/nb s [ 3 :0] s mc 3 4 s mc 3 5 s mc10 s mc11 s mc16 s mc15 s mc22 s mc21 s mc17 s mc1 8 s mc14 s mc1 3 s mc12 s mc1 8 s mc17 s mc16 s mc15 s mc14 s mc1 3 s mc12 s mc1 8 s mc 3 6 s mc16 s mc15 s mc14 s mc1 3 s mc12
873 32054f?avr32?09/09 at32ap7002 figure 40-6. smc signals for nrd and nrw controlled accesses. 40.8.1 sdram signals these timings are given for 10 pf load on sdck and 50 pf on other signals. note: 1. the maximum frequenzy of the sdramc interf ace is the same as the max frequnzy for the hsb. nrd nc s d0 - d 3 1 nwe a2-a25 a0/a1/nb s [ 3 :0] s mc7 s mc19 s mc20 s mc4 3 s mc 3 7 s mc42 s mc 8 s mc1 s mc2 s mc2 3 s mc24 s mc 3 2 s mc7 s mc 8 s mc6 s mc5 s mc4 s mc 3 s mc9 s mc41 s mc40 s mc 3 9 s mc 38 s mc45 s mc9 s mc6 s mc5 s mc4 s mc 3 s mc 33 s mc 3 0 s mc29 s mc26 s mc25 s mc 3 1 s mc44 table 40-19. sdram clock signal. symbol parameter max (1) units 1/(t cpsdck ) sdram controller clock frequency 1/(2t cpcpu )mhz
874 32054f?avr32?09/09 at32ap7002 table 40-20. sdram clock signal. symbol parameter min units sdramc 1 sdcke high before sdck rising edge 6.8 ns sdramc 2 sdcke low after sdck rising edge 5.8 sdramc 3 sdcke low before sdck rising edge 6.8 sdramc 4 sdcke high after sdck rising edge 6.2 sdramc 5 sdcs low before sdck rising edge 6.7 sdramc 6 sdcs high after sdck rising edge 5.9 sdramc 7 ras low before sdck rising edge 6.7 sdramc 8 ras high after sdck rising edge 6.9 sdramc 9 sda10 change before sdck rising edge 6.9 sdramc 10 sda10 change after sdck rising edge 5.7 sdramc 11 address change before sdck rising edge 6.4 sdramc 12 address change after sdck rising edge 4.5 sdramc 13 bank change before sdck rising edge 6.6 sdramc 14 bank change after sdck rising edge 5.2 sdramc 15 cas low before sdck rising edge 7.1 sdramc 16 cas high after sdck rising edge 5.9 sdramc 17 dqm change before sdck rising edge 6.5 sdramc 18 dqm change after sdck rising edge 4.6 sdramc 19 d0-d15 in setup before sdck rising edge 2.3 sdramc 20 d0-d15 in hold after sdck rising edge 3.9 sdramc 21 d16-d31 in setup before sdck rising edge 0.9 sdramc 22 d16-d31 in hold after sdck rising edge 4.0 sdramc 23 sdwe low before sdck rising edge 6.5 sdramc 24 sdwe high after sdck rising edge 7.0 sdramc 25 d0-d15 out valid before sdck rising edge 6.2 sdramc 26 d0-d15 out valid after sdck rising edge 4.1 sdramc 27 d16-d31 out valid befo re sdck rising edge 6.2 sdramc 28 d16-d31 out valid a fter sdck rising edge 4.5
875 32054f?avr32?09/09 at32ap7002 figure 40-7. sdramc signals relative to sdck. ras a0 - a9, a11 - a13 d0 - d15 read sdck sda10 d0 - d15 to write sdramc 1 sdcke sdramc 2 sdramc 3 sdramc 4 sdcs sdramc 5 sdramc 6 sdramc 5 sdramc 6 sdramc 5 sdramc 6 sdramc 7 sdramc 8 cas sdramc 15 sdramc 16 sdramc 15 sdramc 16 sdwe sdramc 23 sdramc 24 sdramc 9 sdramc 10 sdramc 9 sdramc 10 sdramc 9 sdramc 10 sdramc 11 sdramc 12 sdramc 11 sdramc 12 sdramc 11 sdramc 12 ba0/ba1 sdramc 13 sdramc 14 sdramc 13 sdramc 14 sdramc 13 sdramc 14 sdramc 17 sdramc 18 sdramc 17 sdramc 18 dqm0 - dqm3 sdramc 19 sdramc 20 d16 - d31 read sdramc 21 sdramc 22 sdramc 25 sdramc 26 d16 - d31 to write sdramc 27 sdramc 28
876 32054f?avr32?09/09 at32ap7002 41. ordering information table 41-1. ordering information ordering code package package type packing temperature operating range AT32AP7002-CTUR ctbga196 green reel industrial (-40c to 85c) at32ap7002-ctut ctbga196 green tray industrial (-40c to 85c)
877 32054f?avr32?09/09 at32ap7002 42. errata 42.1 rev. c 1. spi fdiv option does not work selecting clock signal using fdiv = 1 does not work as specified. fix/workaround do not set fdiv = 1. 2. spi chip select 0 bits field overrides other chip selects the bits field for chip select 0 overrides bits fields for other chip selects. fix/workaround update chip select 0 bits field to the relevant settings before transmit ting with chip selects other than 0. 3. spi lastxfer may be overwritten when peripheral select (ps) = 0, the lastxfer -bit in the transmit data register (tdr) should be internally discared. this fails and may cause problems during dma transfers. transmitting data using the pdc when ps=0, the size of the transferred data is 8- or 16-bits. the upper 16 bits of the tdr will be written to a random value. if chip select active after transfer (csaat) = 1, the behavior of the chip select will be unpredictable. fix/workaround - do not use csaat = 1 if ps = 0 - use gpio to control chip select lines - select ps=1 and store data for pcs and lastxfer for each data in transmit buffer. 4. spi lastxfer ove rrides chip select the lastxfer bit overrides chip select input when ps = 0 and csaat is used. fix/workaround - do not use the csaat - use gpio as chip select input - select ps = 1. transfer 32-bit with correct lastxfer settings. 5. mmc data write operation with less than 12 bytes is impossible. mci data write operation with less than 12 bytes is impossible. the data write operation with a number of bytes less than 12 leaves the internal mci fifo in an inconsistent state. subsequent reads and writes will not functi on properly. fix/workaround always transfer 12 or more bytes at a time. if less than 12 bytes are transferred, the only recovery mechanism is to perform a software reset of the mci. 6. mmc sdio interrupt only works for slot a if 1-bit data bus width and on other slots than slot a, the sdio interrupt can not be cap- tured.
878 32054f?avr32?09/09 at32ap7002 fix/workaround use slot a. 7. psif txen/rxen may disable the transmitter/receiver writing a '0' to rxen will disable the receiver. writing '0' to txen will disable the transmitter. fix/workaround when accessing the ps/2 control register alwa ys write '1' to rxen to keep the receiver enabled, and write '1' to txen to keep the transmitter enabled. 8. psif txrdy interrupt corrupts transfers when writing to the transmit holding register (thr), the da ta will be transfer red to the data shift register immediately, regardless of the state of the data shift register. if a transfer is ongoing, it will be inte rrupted and a new transfer will be st arted with the new data written to thr. fix/workaround use the txempty-interrupt instead of the txrdy-interrupt to update the thr. this ensures that a transfer is completed. 9. lcd memory error interupt does not work writing to the merit-bit in the lcd interrupt test register (itr) does not cause an interrupt as intended. the meric-bit in the lcd inte rrupt clear register (icr) cannot be written. this means that if the meris-bit in isr is set, it cannot be cleared. fix/workaround memory error interrupt should not be used. 10. pwm counter restarts at 0x0001 the pwm counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period - consecutive periods are 0x0001, 0x0002, ..., period 11. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 12. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 13. pwm channel status may be wrong if disabled before a period has elapsed
879 32054f?avr32?09/09 at32ap7002 before a pwm period has elapsed, the read channel status may be wrong. the chidx-bit for a pwm channel in the pwm enable register will read '1' fo r one full pwm period even if the channel was disabled before the period elapsed. it will then read '0' as expected. fix/workaround reading the pwm channel status of a disabled channel is only correct after a pwm period 14. twi transfer error without ack if the twi does not receive an ack from a slave during the address+r/w phase, no bits in the status register will be set to indicate this. hence, the transf er will neve r complete. fix/workaround to prevent errors due to missing ack, the software should use a timeout mechanism to ter- minate the transfer if this happens. 15. ssc can not transmit or receive data the ssc can not transmit or receive data when cks = ckdiv and cko = none in tcmr or rcmr respectively. fix/workaround set cko to a value that is not "none" and enable the pio with output driver disabled on the tk/rk pin. 16. usart - rxbreak flag is not correctly handled the frame_error is set instead of the rxbr eak when the break character is located just after the stop bit( s) in asynchronous mode. fix/workaround the transmitting uart must set timeguard greater than 0. 17. usart - manchester encoding/decoding is not working. manchester encoding/decoding is not working. fix/workaround do not use manchester encoding. 18. spi - disabling spi has no effect on tdre flag. disabling spi has no effect on tdre whereas the write data command is filtered when spi is disabled. this means that as soon as the spi is disabled it becomes impossible to reset the tdre flag by writing in the spi_tdr. so if the spi is disabled during a pdc transfer, the pdc will continue to write data in the spi_tdr (as tdre keeps high) ti ll its buffer is empty, and all data written after the disable command is lost. fix/workaround disable pdc, 2 nop (minimum), disable spi. when you want to continue the transfer: enable spi, enable pdc. 19. spi disable does not work in slave mode. spi disable does not work in slave mode. fix/workaround read the last received data, then perform a software reset.
880 32054f?avr32?09/09 at32ap7002 21. scc - first data transmitted after reset is not datdef. in the first frame transmitted, the first transm itted data that follows the frame synchro is 0, not datdef. this happens when: 1. pdc is disabled 2. reset the ssc 3. configure the ssc with a transmit start condition different from continuous (start = 0) 4. datdef = 1 5. enable the ssc in transmission. this trouble only appears after a reset and it is only the first frame is affected. fix/workaround use the pdc to fill the thr afte r the enable of the ssc and be fore the start of the frame. 21. mci - false data time out error dtoe may occur. if a small block (5 bytes) is read through the read_single_block command (cmd17), the flag notbusy will be set and a false data timeout error dtoe occurs. fix/workaround none. 22. sdram - self-refresh mode if entry in self-refresh mode is followed by sdram access and auto-refresh event, trc tim- ing is not checked for auto_refresh sequence. fix/workaround set the value of tras field in user interface with trc+1. 23. spi - no tx underrun flag available there is no tx underrun flag av ailable, therefore in slave mode there is no way to be informed of a character lost in transmission. fix/workaround pdc/pdca transfers: none. manual transfers (no pdc and tx slave only): read the rhr every time the thr is written. the ovrs flag of the status register will track any underrun on the tx side. 24. hmatrix - fixed priority arbitration does not work fixed priority arbitration does not work. fix/workaround use round-robin arbitration instead. 25. osc32 is not available for rtc, wdt, timers and usarts at startup right after startup the osc32 clock to internal modules is not valid. the osc32 clock will be valid for use approximately 128 osc32 cycles af ter the the first instruction is executed. this has consequences if you are planning to use the rtc, wdt, going into sleep mode and usarts with sck and tcs with timer_clock0.
881 32054f?avr32?09/09 at32ap7002 fix/workaround before executing any code the user should enable the rtc with the smallest prescaler and poll that the rtc is counting before doing anything in your program. another way to ensure that the osc32 is valid is to use interrupts with top=1. example: //reset the counter register avr32_rtc.val = 0x0; //enable the rtc with the smallest prescaler avr32_rtc.ctrl = 0x1; //wait until the value increases while(avr32_rtc.val == 0); 26. spi can generate a false rxready signal in slave mode in slave mode the spi can generate a false rxready signal during enabling of the spi or dur- ing the first transfer. fix/workaround 1. set slave mode, set required cpol/cpha 2. enable spi 3. set the polarity cpol of the line in the opposite value of the required one 4. set the polarity cpol to the required one. 5. read the rxholding register transfers can now begin and rxr eady will now behave as expected. 27. ebi address lines 23, 24, and 25 are pulled up when booting up after reset the ebi address lines 23, 24 and 25 are tristated with pullups. booting from a flash larger than 8 mb using these lines will fa il, as the flash will be accessed with these address bits set. fix/workaround add external pulldown resistors (5 k ) on these lines if booting from a flash larger than 8 mb using these address lines. 28. ssc - additional delay on td output a delay from 2 to 3 system clock cycles is added to td output when: tcmr.start = receive start, tcmr.sttdly = more than zero, rcmr.start = start on falling edge / start on rising edge / start on any edge rfmr.fsos = none (input) fix/workaround none. 29. ssc - tf output is not correct tf output is not correct (at least emitted one serial clock cycle later than expected) when: tfmr.fsos = driven low during data transfer/ driven high during data transfer
882 32054f?avr32?09/09 at32ap7002 tcmr.start = receive start rfmr.fsos = none (input) rcmr.start = any on rf (edge/level) fix/workaround none. 30. usart - txd signal is floating in modem and hardware handshaking mode the txd signal is floating in modem and hardware handshaking mode, but should be pulled up. fix/workaround enable pullup on this line in the pio. 31. pwm - impossible to update a period equal to 0 by using the cupd register it is impossible to update a period equal to 0 by the using of the update register (cupd). fix/workaround to update a period equal to 0, write directly to the cprd register. 32. wdt clear is blocked after wdt reset a watchdog timer event will, after reset, block writes to the wdt_clear register, prevent- ing the program to clear the next watchdog timer reset. fix/workaround if the rtc is not used a write to avr32_rtc.ctrl.pclr = 1, instead of writing to avr32_wdt.clr, will reset the prescaler and th us prevent the watchd og event from happen- ing. this will render the rtc useless, but prevents wdt reset because the rtc and wdt share the same prescaler. anot her sideeffect of this is that the watchdog timeout period will be half the expected timeout period. if the rtc is used one can disable the watchdog timer (wdt) after a wdt reset has occured. this will prev ent the wdt resetting the system. to make the wdt functional again a hard reset (power on reset or reset_n) must be applied. if you still want to use the wdt after a wdt reset a small code can be inserted at the startup checking the avr32_pm.rcause register for wdt reset and use a gpio pin to reset the system. this method requires that one of the gpio pins ar e available and connected externally to the reset_n pin. after the gpio pin has pulled down the reset line the gpio will be reset and leave the pin tristated with pullup. 33. usart - the dcd signal is active high from the usart, but should be active low the dcd signal is active high from the usart, but should be active low. fix/workaround an inverter should be added on this line on the pcb. 34. mci transmit data regi ster (tdr) fifo corruption if the number of bytes to be transmitted by the mci is not a multiple of 4, the transmit data register (tdr) first in first ou t data buffer control logic w ill become corrupted when trans- mit data is written to the tdr as 32-bit values. fix/workaround
883 32054f?avr32?09/09 at32ap7002 configure the mci mode register (mr) to accept 8-bit data input by writing a 1 to bit 13 (fbyte), and transfer each byte of the transmit data to tdr by right aligning the useful value. this allows the number of bytes transferred into the tdr to match the number set up in the bcnt field of the mci block register (blkr). 35. unreliable branch folding in certain situations, branch folding does not work as expected. fix/workaround write 0 to cpucr.fe before executing any branch instructions after reset. 36. usb pll jitter may cause packet loss during usb hi-speed transmission the usb hi-speed pll accuracy is not suffic ient for isochronous usb hi-speed transmis- sion and may cause packet loss. the obse rved bit-loss is typically < 125 ppm. fix/workaround do not use isochronous mode if absolute data accuracy is critical. 42.2 rev. b not sampled. 42.3 rev. a not sampled.
884 32054f?avr32?09/09 at32ap7002 43. datasheet revision history please note that the referring page numbers in th is section are referred to this document. the referring revision in this section are referring to the document revision. 43.1 rev. f 09/09 43.2 rev. e 09/09 43.3 rev. d 09/07 1. updated ?errata? on page 877 . 1. updated ?errata? on page 877 . 1. pio controller c multiplexing table updated in ?peripherals? on page 75 ?. 2. added section ?usba? on page 81 in clock connections in ?peripherals? on page 75 . 3. usba feature list updated in ?peripherals? on page 75 . 4. renamed clk_slow to clk_osc32 in table 9-4 on page 80 . 5 updated organisation of user interface in ?hsb bus matrix (hmatrix)? on page 142 . 6. updated special bus granting mechanism in ?hsb bus matrix (hmatrix)? on page 142 . 7. added product dependencies in ?dma controller (dmaca)? on page 165 . 8. added product dependencies in ?peripheral dma controller (pdc)? on page 233 . 9. added description of multi-drive in ?parallel input/output controller (pio)? on page 249 . 10 added mder/mddr/mdsr to pin logic diagram in ?parallel input/output controller (pio)? on page 249 . 11. spi pins must be enabled to use local loopback. 12. updated description of the ovres bit in ?spi status register? on page 310 . 13. updated bit description of txempty in the ?usart channel status register? on page 432 . 14. number of chip select lines updatedin figur es and tables, changed from 8 to 6 in ?static memory controller (smc)? on page 489 . 15. made the mdr register read/write instead of read in ?sdram controller (sdramc)? on page 532 . 16. removed the pwsen and pwsdis bits from the ?mci control register? on page 585 . 17. added pdcfbyte and removed the pwsdiv bits from the ?mci mode register? on page 586 . 18. added note about reading the status register clears the interrupt flag in ?timer/counter (tc)? on page 740 . 19. added debug operation to product dependencies in ?timer/counter (tc)? on page 740 . 20. added debug operation to product dependencies in ?pulse width modulation controller (pwm)? on page 774 .
885 32054f?avr32?09/09 at32ap7002 43.4 rev. c 07/07 43.5 rev. b 04/07 21. consistently used the term lcdc core clock through the document when referring to the generic clock that drives the lcd core and is used to generate pclk and the other lcd synchronization signals. 22. updated typos in ?lcd controller (lcdc)? on page 800 . 23. rewritten the register configuration guide and renamed it ?register configuration example? in ?lcd controller (lcdc)? on page 800 . 24. updated formula for pixel clock in ?lcd control register 1? on page 840 . 25. updated hozval description in ?lcd frame configuration register? on page 845 . 26. updated ?pll characteristics? on page 933 . 27. updated ?errata? on page 877 . 1. updated ?part description? on page 2 . 2. pc signals removed in ?signals description? on page 5 3. usb signals updated in ?signals description? on page 5 . 4. the px0 - px53 signals added in ?signals description? on page 5 . 5. sdcs signals removed from pio controller multiplexing tables in ?peripherals? on page 79 . 6. mac references removed form tables in ?memories? on page 77 . 7. mac controller references removed in ?peripheral overview? on page 94 . 8. sdcs1 signal removed from figures and tables, and sdcs0 renamed to sdcs in ?external bus interface (ebi)? on page 154 . 9. smartmedia renamed to nand flash in some description to avoid confusion in ?external bus interface (ebi)? on page 154 . 10. updated application block diagram in figure 21-2 on page 314 . 11. updated the reset state of the smc mode register in table 27-9 on page 523 . 12. updated ?mechanical characteristics? on page 927 . 13. updated pad parameters in ?dc characteristics? on page 862 . 14. updated ?power consumption by peripheral in active mode? on page 864 , lcd and macb excluded. 15. updated pad parameters in ?clock characteristics? on page 865 . 16. updated ?usb transceiver characteristics? on page 868 . 17. updated ?ebi timings? on page 939 . 1. updated ?features? on page 1 . 2. updated tables in ?signals description? on page 4 . 3. updated table 9-2 on page 77 , table 9-9 on page 82 , and table 9-10 on page 83 in the ?peripherals? on page 75 . 4. updated module names and abbreviations through the datasheet.
886 32054f?avr32?09/09 at32ap7002 43.6 rev. a 02/07 1. initial revision.
i 32054f?avr32?09/09 at32ap7002 table of contents features ................ ................ .............. ............... .............. .............. ............ 1 1 part description ......... ................ ................. ................ ................. ............ 2 2 signals description ............ .............. ............... .............. .............. ............ 3 3 power considerations ........ .............. ............... .............. .............. ............ 8 3.1power supplies .........................................................................................................8 3.2power supply connections .......................................................................................8 4 package and pinout ................. ................ ................. ................ ............... 9 4.1avr32ap7001 ..........................................................................................................9 5 blockdiagram ............. ................ ................. ................ ................. .......... 11 6 i/o line considerations ...... .............. ............... .............. .............. .......... 15 6.1jtag pins ................................................................................................................15 6.2wake_n pin ............. ................. ................ ................ ................ ................ .............15 6.3reset_n pin ............ ................. ................ ................ ................ ................ .............15 6.4evti_n pin ..............................................................................................................15 6.5twi pins ..................................................................................................................1 5 6.6pio pins ................................................................................................................... 15 7 avr32 ap cpu ........... ................ ................. ................ ................. .......... 16 7.1avr32 architecture .................................................................................................16 7.2the avr32 ap cpu ...............................................................................................16 7.3programming model ................................................................................................22 8 pixel coprocessor (p ico) .............. ................. .............. .............. .......... 25 8.1features ..................................................................................................................2 5 8.2description ..............................................................................................................25 8.3block diagram .........................................................................................................26 8.4vector multiplication unit (vmu) ..............................................................................27 8.5input pixel selector .................................................................................................27 8.6output pixel inserter ................................................................................................29 8.7user interface ..........................................................................................................31 8.8pico instructions ....................................................................................................49 8.9data hazards ..........................................................................................................70 9 memories ............... .............. .............. ............... .............. .............. .......... 71
ii 32054f?avr32?09/09 at32ap7002 9.1embedded memories ..............................................................................................71 9.2physical memory map .............................................................................................71 10 peripherals ............ .............. .............. ............... .............. .............. .......... 73 10.1peripheral address map ........................................................................................73 10.2interrupt request signal map ................................................................................75 10.3dmaca handshake interface map .......................................................................77 10.4clock connections ................................................................................................78 10.5external interrupt pin mapping ..............................................................................79 10.6nexus ocd aux port connections .......................................................................79 10.7peripheral multiplexing on io lines ........................................................................80 10.8peripheral overview ...............................................................................................94 11 power manager (pm) ......... .............. .............. .............. .............. ........... 100 11.1features ..............................................................................................................100 11.2description ..........................................................................................................100 11.3block diagram .....................................................................................................101 11.4product dependencies ........................................................................................102 11.5functional description .........................................................................................102 11.6user interface ......................................................................................................115 12 real time counter (rtc) .. ............. .............. .............. .............. ........... 124 12.1features ..............................................................................................................124 12.2description ..........................................................................................................124 12.3block diagram .....................................................................................................124 12.4product dependencies ........................................................................................124 12.5functional description .........................................................................................125 12.6user interface ......................................................................................................126 13 watchdog timer (wdt) ......... ................ ................. ................ ............. 131 13.1features ..............................................................................................................131 13.2description ..........................................................................................................131 13.3block diagram .....................................................................................................131 13.4product dependencies ........................................................................................131 13.5functional description .........................................................................................132 13.6user interface ......................................................................................................133 14 interrupt controller (intc) ............. .............. .............. .............. ........... 135 14.1features ..............................................................................................................135
iii 32054f?avr32?09/09 at32ap7002 14.2overview .............................................................................................................135 14.3block diagram .....................................................................................................135 14.4product dependencies ........................................................................................136 14.5functional description .........................................................................................136 14.6user interface ......................................................................................................138 15 external interrupt controller (eic) ..... .............. .............. ............ ........ 142 15.1features ..............................................................................................................142 15.2description ..........................................................................................................142 15.3block diagram .....................................................................................................142 15.4product dependencies ........................................................................................142 15.5functional description .........................................................................................143 15.6user interface ......................................................................................................144 16 hsb bus matrix (hmatrix) .. ................ ................. ................ ............. 148 16.1features .............................................................................................................148 16.2overview .............................................................................................................148 16.3product dependencies ........................................................................................148 16.4functional description .........................................................................................148 16.5user interface ......................................................................................................152 17 external bus interface (ebi ) ................ .............. .............. ............ ........ 161 17.1features ..............................................................................................................161 17.2description ..........................................................................................................161 17.3block diagram .....................................................................................................162 17.4i/o lines description ...........................................................................................164 17.5application example ............................................................................................166 17.6product dependencies ........................................................................................173 17.7functional description .........................................................................................173 18 dma controller (dm aca) .................... .............. .............. ............ ........ 181 18.1features ..............................................................................................................181 18.2overview .............................................................................................................181 18.3block diagram .....................................................................................................182 18.4product dependencies ........................................................................................182 18.5functional description .........................................................................................183 18.6arbitration for hsb master interface ...................................................................188 18.7memory peripherals ............................................................................................188 18.8handshaking interface ........................................................................................188
iv 32054f?avr32?09/09 at32ap7002 18.9dmaca transfer types ......................................................................................190 18.10programming a channel ...................................................................................194 18.11disabling a channel prior to transfer completion ............................................211 18.12user interface ....................................................................................................213 19 peripheral dma controller (pdc) ................ .............. .............. ........... 244 19.1features ..............................................................................................................244 19.2description ..........................................................................................................244 19.3block diagram .....................................................................................................245 19.4product dependencies ........................................................................................246 19.5functional description .........................................................................................246 19.6peripheral dma controller (pdc) user interface ...............................................249 20 parallel input/output contro ller (pio) ......... .............. .............. ........... 260 20.1features ..............................................................................................................260 20.2description ..........................................................................................................260 20.3block diagram .....................................................................................................261 20.4product dependencies ........................................................................................262 20.5functional description .........................................................................................263 20.6i/o lines programming example ........................................................................267 20.7user interface ......................................................................................................269 21 serial peripheral interface (spi) ................ ................ .............. ........... 300 21.1features ..............................................................................................................300 21.2description ..........................................................................................................300 21.3block diagram .....................................................................................................301 21.4application block diagram ..................................................................................302 21.5signal description ...............................................................................................303 21.6product dependencies ........................................................................................304 21.7functional description .........................................................................................305 21.8serial peripheral interface (spi) user interface ..................................................315 22 two-wire interface (twi) .... .............. ............... .............. .............. ........ 329 22.1features .............................................................................................................329 22.2description ..........................................................................................................329 22.3block diagram .....................................................................................................329 22.4application block diagram ..................................................................................329 22.5product dependencies ........................................................................................330 22.6functional description .........................................................................................331
v 32054f?avr32?09/09 at32ap7002 22.7twi user interface ..............................................................................................336 23 ps/2 module (psif) ........... .............. .............. .............. .............. ........... 347 23.1features ..............................................................................................................347 23.2description ..........................................................................................................347 23.3product dependencies ........................................................................................347 23.4the ps/2 protocol ...............................................................................................347 23.5functional description .........................................................................................349 23.6user interface ......................................................................................................350 24 synchronous serial controller (ssc) .... ................. ................ ........... 359 24.1features .............................................................................................................359 24.2overview .............................................................................................................359 24.3block diagram .....................................................................................................360 24.4application block diagram ..................................................................................360 24.5i/o lines description ...........................................................................................361 24.6product dependencies ........................................................................................361 24.7functional description .........................................................................................361 24.8ssc application examples ..................................................................................373 24.9user interface ......................................................................................................375 25 universal synchr onous/asynchronous receiver/t ransmitter (usart) 399 25.1features ..............................................................................................................399 25.2overview .............................................................................................................399 25.3block diagram .....................................................................................................400 25.4application block diagram ..................................................................................401 25.5i/o lines description ..........................................................................................401 25.6product dependencies ........................................................................................402 25.7functional description .........................................................................................403 25.8usart user interface ........................................................................................433 25.9usart version register .....................................................................................453 26 ac97 controller (ac97c) .......... ................. ................ .............. ........... 454 26.1features .............................................................................................................454 26.2description ..........................................................................................................454 26.3block diagram .....................................................................................................455 26.4pin name list ......................................................................................................456 26.5application block diagram ..................................................................................456
vi 32054f?avr32?09/09 at32ap7002 26.6product dependencies ........................................................................................457 26.7functional description .........................................................................................458 26.8ac97 controller (ac97c) user interface ............................................................469 27 audio bitstream dac (abdac) .............. ................. ................ ........... 486 27.1features ..............................................................................................................486 27.2description ..........................................................................................................486 27.3block diagram .....................................................................................................487 27.4pin name list ......................................................................................................487 27.5product dependencies ........................................................................................487 27.6functional description .........................................................................................488 27.7audio bitstream dac user interface ...................................................................490 27.8frequency response ..........................................................................................498 28 static memory controller (smc) ......... .............. .............. ............ ........ 499 28.1features .............................................................................................................499 28.2overview .............................................................................................................499 28.3block diagram .....................................................................................................500 28.4i/o lines description ...........................................................................................500 28.5product dependencies ........................................................................................501 28.6functional description .........................................................................................501 28.7user interface ......................................................................................................534 29 sdram controller (sdramc) ................ ................. ................ ........... 541 29.1features ..............................................................................................................541 29.2overview .............................................................................................................541 29.3block diagram .....................................................................................................542 29.4i/o lines description ...........................................................................................542 29.5application example ............................................................................................543 29.6product dependencies ........................................................................................546 29.7functional description .........................................................................................547 29.8user interface ......................................................................................................556 30 error corrected code (ecc ) controller ...... .............. .............. ........... 569 30.1features .............................................................................................................569 30.2description ..........................................................................................................569 30.3block diagram .....................................................................................................569 30.4functional description .........................................................................................570 30.5ecc user interface .............................................................................................574
vii 32054f?avr32?09/09 at32ap7002 31 multimedia card interface (m ci) ........... ................. ................ ............. 580 31.1features ..............................................................................................................580 31.2overview .............................................................................................................580 31.3block diagram .....................................................................................................581 31.4application block diagram ..................................................................................582 31.5i/o lines description ...........................................................................................582 31.6product dependencies ........................................................................................583 31.7functional description .........................................................................................583 31.8user interface ......................................................................................................594 32 hi-speed usb interface (usba) ............. ................. ................ ........... 614 32.1features ..............................................................................................................614 32.2description ..........................................................................................................614 32.3block diagram .....................................................................................................615 32.4product dependencies ........................................................................................615 32.5typical connection ..............................................................................................616 32.6usb v2.0 high speed device introduction .........................................................617 32.7usb high speed device (u sba) user interfac e ................ ............ ............. ........640 33 timer/counter (tc) ........... .............. .............. .............. .............. ........... 688 33.1features ..............................................................................................................688 33.2overview .............................................................................................................688 33.3block diagram .....................................................................................................689 33.4i/o lines description ...........................................................................................689 33.5product dependencies ........................................................................................689 33.6functional description .........................................................................................690 33.7user interface ......................................................................................................705 34 pulse width modulation c ontroller (pwm) . .............. .............. ........... 725 34.1features ..............................................................................................................725 34.2description ..........................................................................................................725 34.3block diagram .....................................................................................................726 34.4i/o lines description ...........................................................................................726 34.5product dependencies ........................................................................................727 34.6functional description .........................................................................................728 34.7pulse width modulation (pwm) controller user interface ..................................736 35 image sensor interface (isi) ............. ............... .............. .............. ........ 751 35.1features ..............................................................................................................751
viii 32054f?avr32?09/09 at32ap7002 35.2overview .............................................................................................................751 35.3block diagram .....................................................................................................752 35.4product dependencies ........................................................................................752 35.5functional description .........................................................................................753 35.6image sensor interface (isi) user interface ........................................................761 36 on-chip debug ......... ................ ................ ................. ................ ........... 781 36.1features ..............................................................................................................781 36.2overview .............................................................................................................781 36.3block diagram ......................................................................................................782 36.4functional description .........................................................................................782 37 jtag and boundary scan ......... ................. ................ .............. ........... 788 37.1features ..............................................................................................................788 37.2overview .............................................................................................................788 37.3block diagram ......................................................................................................789 37.4functional description .........................................................................................789 37.5jtag instruction summary .................................................................................794 37.6public jtag instructions .....................................................................................795 37.7private jtag instructions ....................................................................................796 37.8jtag data registers ..........................................................................................802 37.9sab address map ...............................................................................................803 38 boot sequence ........... ................ ................. ................ .............. ........... 804 38.1starting of clocks .................................................................................................804 38.2fetching of initial instructions ..............................................................................804 39 mechanical characteristics ..... ................ ................. ................ ........... 805 39.1avr32ap7001 ....................................................................................................805 40 electrical characteristics ... .............. ............... .............. .............. ........ 808 40.1absolute maximum ratings .................................................................................808 40.2dc characteristics ..............................................................................................808 40.3power consumption ............................................................................................809 40.4clock characteristics ...........................................................................................811 40.5crystal oscillator characteristics .........................................................................813 40.6usb transceiver characteristics .........................................................................814 40.7ac characteristics ...............................................................................................816 40.8ebi timings .........................................................................................................816
ix 32054f?avr32?09/09 at32ap7002 41 ordering information .......... .............. ............... .............. .............. ........ 822 42 errata ........... ................ ................ ................. ................ .............. ........... 823 42.1rev. c .................................................................................................................823 42.2rev. b ..................................................................................................................82 9 42.3rev. a ..................................................................................................................82 9 43 datasheet revision history .. ................ ................. ................ ............. 830 43.1rev. f 09/09 ........................................................................................................830 43.2rev. e 01/08 ........................................................................................................830 43.3rev. d 09/07 .......................................................................................................830 43.4rev. c 07/07 .......................................................................................................831 43.5rev. b 04/07 ........................................................................................................831 43.6rev. a 02/07 ........................................................................................................831 table of contents.......... ................. ................ ................. ................ ........... i
32054f?avr32?09/09 headquarters international atmel corporation 2325 orchard parkway san jose, ca 95131 usa tel: 1(408) 441-0311 fax: 1(408) 487-2600 atmel asia unit 1-5 & 16, 19/f bea tower, millennium city 5 418 kwun tong road kwun tong, kowloon hong kong tel: (852) 2245-6100 fax: (852) 2722-1369 atmel europe le krebs 8, rue jean-pierre timbaud bp 309 78054 saint-quentin-en- yvelines cedex france tel: (33) 1-30-60-70-00 fax: (33) 1-30-60-71-11 atmel japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel: (81) 3-3523-3551 fax: (81) 3-3523-7581 product contact web site www.atmel.com technical support avr32@atmel.com sales contact www.atmel.com/contacts literature requests www.atmel.com/literature disclaimer: the information in this document is provided in connection with atmel products. no license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in atmel?s terms and condi- tions of sale located on atmel?s web site, atmel assumes no li ability whatsoever and disclaims any express, implied or statutor y warranty relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particu lar purpose, or non-infringement. in no event shall atmel be liable for any direct, indirect, consequential, punitive, special or i nciden- tal damages (including, without limitation, damages for loss of profits, business interruption, or loss of information) arising out of the use or inability to use this document, even if atme l has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or comp leteness of the contents of this document and reserves the rig ht to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information contained her ein. unless specifically provided otherwise, atmel products are not suitable for, and shall not be used in, automotive applications. atmel?s products are not int ended, authorized, or warranted for use as components in applications in tended to support or sustain life. ? 2009 atmel corporation. all rights reserved. atmel ? , atmel logo and combinations thereof, avr ? , avr ? logo and others are registered trade- marks or trademarks of atmel corporation or its subsidiari es. other terms and product names may be trademarks of others.


▲Up To Search▲   

 
Price & Availability of AT32AP7002-CTUR

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X